-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Steel as an optional plugin system #8675
base: master
Are you sure you want to change the base?
Conversation
Just curious why Scheme instead of writing packages in Rust itself? Part of the reason I use Helix is because everything is in Rust and can be very performant. I worry if people start writing many popular plugins in Steel that we might get a situation like neovim which is slowed down by package loading and general performance speed, as it seems like Steel can be as slow as Python, even Lua which is neovim's plug-in language is faster than that. |
I don't see what needs to be particularly performant about helix, apart from opening large files in a timely manner, which happens regardless of the plugin system. Compiled plugins are not cross compatible between all the architectures that helix can run on, and it's also much less approachable. rust is from what I've seen not an easy language to grasp, even if you have programming experience. Its syntax and concepts can be hard to understand. A plugin system making use of scheme makes all of this much easier. The plugins are cross-compatible since the plugin-system is part of the editor itself, and the language is very simplistic (which doesn't have to be a bad thing, and emacs is proof for that. scheme is merely a lisp dialect) |
@satvikpendem I'm sharing this explanation here for you, and for anyone else reviewing this PR, who may wonder why your comment was downvoted so quickly. It’s generally expected—out of courtesy for everyone involved—that before asking a question, you take a moment to see if the answer is readily available. More than 50 people are subscribed to the updates on this PR, and many of them may be feeling fatigued by having to re-answer questions that have already been addressed multiple times. In this case, the answer to your question can be found by searching for “plugin” in the Helix discussions, specifically looking at the top-rated thread (#3806). You can also Google it... there are Reddit threads and other sources that cover this topic thoroughly. |
@lcpichette I see, thank you, I didn't think to look in the discussions tab (truthfully I personally never use the discussions tab myself for my own projects and those I contribute to so that's probably why), I just searched the issues tab. I appreciate the response. |
If at some point there's going to be an LSP for Steel as well as a formatter, would it make sense to ship those with the editor so that users don't even need to configure it? |
There is an LSP for steel already. For formatting, I don't have one specifically for steel, but have been using |
I came across the PR and I just wanted to say it looks really exciting. As a long-time Emacs user I know that a Lisp would be great for writing plugins (I love being able to tweak them, without the need to restart my editor) and I think once this is merged Helix will be extremely competitive with neovim and Emacs. I hope this will land in the next major Helix release is some shape or form! |
I'm just average user, who wants an editor that just predictable work. I've tried several editions of Emacs, Vim, NeoVim with no success because of plugins break and slow everything. And they want me learning new language just to use my editor(lisp is great anyway ^_^) The same case with MacOS/Iphone. They just work as expected. Zed has failed recently and has been removed because of "doesn't start GPU issues...who cares how fast it is if it's broken". It might be fallback/backup/supervisors(like Erlang) to be sure editor works in every moment and let me fix bugs and make new features in my code for business. I'm too old and tired to be tuning my editor again and again. |
I understand your frustration with breakage in plugins. I myself switched to Helix exactly because of the issue you're describing. But:
You likely won't need to learn the language unless you want to extend the editor with custom functionality. For simple configuration, the scheme config will be easy to use like the current TOML one
Since Helix has a lot more built-in than Neovim when plugins eventually arrive the average Helix user will likely use significantly less plugins than the average Neovimmer. Less plugins = less chance things will be set on fire. When I was rolling Neovim I had somewhat like 60 plugins. Each of those plugins Helix replaces out of the box for me |
I've seen this comment many times, about how plugins introduce a risk of breaking everything. I'd hope there is enough faith in the process that I wouldn't build something that would run into this drastic failure mode. Default helix has great functionality, if you have no plugins, it behaves as it has always behaved. The architecture I've chosen to operate should give the ability to load one plugin at a time. The failure of one plugin to load should not affect another plugin. Of course, a plugin might become stale or outdated relative to helix / the host environment, and run into issues post upgrade - this happens with VSCode or IntelliJ or any other editor as well really. If that is the case, the one plugin should fail to load, but the rest will continue on as usual assuming all is good. I've also taken care for things such as interrupting any currently running commands; so lets say you just write an infinite loop as a command - you should be able to interrupt it and regain control of the UI. In the worst case, lets say I do break every plugin, which happens while I'm developing this - I still can use the base level editor that works great. LSP, syntax highlighting, all the built in commands - everything would still behave as usual. |
I've tried "hx --tutor" this week and I'm impressed by how fast and easy it works. "Select and do action" is the most understandable and common pattern in my daily work I do in every editor. I just need to forget some patterns from vim like "dd" and do select first. Probably I will tune some keys in the helix. |
That's what I say about "like Erlang supervisors". If plugin fails, editor just disable it and ask user one time. Instead of Neovim behavior (it annoys with repeated notification of some lsp not installed or failed or plugin updated/not updated. I would prefer to enter some "Zen mode" that silence everything else that not my code even lsp. I usually do tests, linting, other stuff from os terminal and not care about embedded git, terminal, cool things of IDE (that's to you, VSCode, you're too much within your ego 😅) |
I couldn't agree more! The plugin system will offer numerous possibilities for customizing the editor, which are currently beyond our reach. In my opinion, it will facilitate the adoption of the editor by a wider audience. For instance, I spent approximately two weeks trying to use Helix, but it significantly reduced my productivity compared to Neovim. The primary issue was Copilot and spellchecking. Additionally, there were numerous minor features in Vim that Helix lacked, making it inconvenient. For example, in Helix, you can’t center text using the
into this one:
is impossible with Helix (the number of Most of you probally will never need to do that, but I do! A lot! Hence, if Helix has a plugin system now, I might be able to create some code to add this small functionality and continue to work. If a plugin system does not happen, I am pretty sure Helix devs will never put such a feature into core just for me :D |
you're not the first to suggest align text in Helix. I think this is generally useful to have in a text editor, so I've opened a PR for it: align-text-helix.mp4
Since Helix doesn't have a built-in spellchecker, I am using the here's my config: [[language]]
name = "markdown"
language-servers = ["typos-lsp"]
[language-server.typos-lsp]
command = "typos-lsp" |
Thanks for the suggestions! I tried |
@ronisbr .. another option for a spell checker is vale and vale-lsp, I think it supports Portuguese. The wiki has an entry for it. https://github.com/helix-editor/helix/wiki/Language-Server-Configurations#vale-ls |
Any plan to land this plugin system? any alternative method to support GNU Global Tag System (gtags) in Helix? clangd is slow for large codebase like Linux kernel. |
You can write an LSP to support gtags. Someone did so for ctags: https://github.com/yowu/ctags_ls & https://github.com/netmute/ctags-lsp |
Work in progress for language configuration
<<<<<<< HEAD | ||
code-gen: Generate files associated with steel | ||
steel: Install steel | ||
======= | ||
theme-check: Check that theme files in runtime/themes are valid. | ||
>>>>>>> origin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to note that some merge-conflicts sneaked in here (as well for commented-out code in helix-term/src/commands/typed.rs
)
Notes:
Opening this just to track progress on the effort and gather some feedback. There is still work to be done but I would like to gather some opinions on the direction before I continue more.
You can see my currently functioning helix config here and there are instructions listed in the
STEEL.md
file. The main repo for steel lives here, however much documentation is in works and will be added soon.The bulk of the implementation lies in the
engine.rs
andscheme.rs
files.Design
Given prior conversation about developing a custom language implementation, I attempted to make the integration with Steel as agnostic of the engine as possible to keep that door open.
The interface I ended up with (which is subject to change and would love feedback on) is the following:
If you can implement this, the engine should be able to be embedded within Helix. On top of that, I believe what I have allows the coexistence of multiple scripting engines, with a built in priority for resolving commands / configurations / etc.
As a result, Steel here is entirely optional and also remains completely backwards compatible with the existing toml configuration. Steel is just another layer on the existing configuration chain, and as such will be applied last. This applies to both the
config.toml
and thelanguages.toml
. Keybindings can be defined via Steel as well, and these can be buffer specific, language specific, or global. Themes can also be defined from Steel code and enabled, although this is not as rigorously tested and is a relatively recent addition. Otherwise, I have been using this as my daily driver to develop for the last few months.I opted for a two tiered approach, centered around a handful of design ideas that I'd like feedback on:
The first, there is a
init.scm
and ahelix.scm
file - thehelix.scm
module is where you define any commands that you would like to use at all. Any function exposed via that module is eligible to be used as a typed command or via a keybinding. For example:This would then make the command
:shell
available, and it will just replace the%
with the current file. The documentation listed in the@doc
doc comment will also pop up explaining what the command does:Once the
helix.scm
module isrequire
'd - then theinit.scm
file is run. One thing to note is that thehelix.scm
module does not have direct access to a running helix context. It must act entirely stateless of anything related to the helix context object. Runninginit.scm
gives access to a helix object, currently defined as*helix.cx*
. This is something I'm not sure I particularly love, as it makes async function calls a bit odd - I think it might make more sense to make the helix context just a global inside of a module. This would also save the hassle that every function exposed has to accept acx
parameter - this ends up with a great deal of boilerplate that I don't love. Consider the following:Every function call to helix built ins requires passing in the
cx
object - I think just having them be able to reference the global behind the scenes would make this a bit ergonomic. The integration with the helix runtime would make sure whether that variable actually points to a legal context, since we pass this in via reference, so it is only alive for the duration of the call to the engine.Async functions
Steel has support for async functions, and has successfully been integrated with the tokio runtime used within helix, however it requires constructing manually the callback function yourself, rather than elegantly being able to use something like
await
. More to come on this, since the eventual design will depend on the decision to use a local context variable vs a global one.Built in functions
The basic built in functions are first all of the function that are typed and static - i.e. everything here:
However, these functions don't return values so aren't particularly useful for anything but their side effects to the editor state. As a result, I've taken the liberty of defining functions as I've needed/wanted them. Some care will need to be decided what those functions actually exposed are.
Examples
Here are some examples of plugins that I have developed using Steel:
File tree
Source can be found here
filetree.webm
Recent file picker
Source can be found here
recent-files.webm
This persists your recent files between sessions.
Scheme indent
Since steel is a scheme, there is a relatively okay scheme indent mode that only applied on
.scm
files, which can be found here. The implementation requires a little love, but worked enough for me to use helix to write scheme code 😄Terminal emulator
I did manage to whip up a terminal emulator, however paused the development of it while focusing on other things. When I get it back into working shape, I will post a video of it here. I am not sure what the status is with respect to a built in terminal emulator, but the one I got working did not attempt to do complete emulation, but rather just maintained a shell to interact with non-interactively (e.g. don't try to launch helix in it, you'll have a bad time 😄 )
Steel as a choice for a language
I understand that there is skepticism around something like Steel, however I have been working diligently on improving it. My current projects include shoring up the documentation, and working on an LSP for it to make development easier - but I will do that in parallel with maintaining this PR. If Steel is not chosen and a different language is picked, in theory the API I've exposed should do the trick at least with matching the implementation behavior that I've outlined here.
Pure rust plugins
As part of this, I spent some time trying to expose a C ABI from helix to do rust to rust plugins directly in helix without a scripting engine, with little success. Steel supports loading dylibs over a stable abi (will link to documentation once I've written it). I used this to develop the proof of concept terminal emulator. So, you might not be a huge fan of scheme code, but in theory you can write mostly Rust and use Steel as glue if you'd like - you would just be limited to the abi compatible types.
System compatibility
I develop off of Linux and Mac - but have not tested on windows. I have access to a windows system, and will get around to testing on that when the time comes.