helix
helix copied to clipboard
snippet support
not exactly a feature request, more of request to implement a feature (or whether to wait until extensions are supported).
I've been working on what I hope will be a cross editor snippet manager (link to project) where the client and server are written in rust. while I'm looking to support a few features not covered in the specification (hoping to achieve eventual feature parity with ultisnips), the syntax I'm working to support is a superset of the syntax defined in the lsp specification.
even with support for only basic dynamic snippets(ie vscode snippets), a major usecase is reducing the amount of effort to support snippets by emerging editors to defining the interface (similar to the benefit of the LSP).
the project is at the point to where I can get completions per keystroke and insert/navigate snippets in vscode, but I'm depending on features specific to vscode. Working to support vscode first is also slowing me down because I really dislike/suck with javascript.
I'm aware that extension support is ongoing, but this also might be supportable by the editor itself (I'm trying to make it to where client implementation should be very little code) and also would make sense to a certain degree given that, while no language server (that I know of) handles snippets, snippets are a part of the LSP specification.
Hi! sniper sounds like a very interesting project!
I assume @archseer's intention was to support LSP snippets natively so I don't know if sniper support will be a built-in feature (it is also obviously very young). At any rate, I hope we can at least see a plugin for that at some point hence the A-plugin label.
Regarding an eventual built-in support, if @archseer is favorable, you may want to get involved with helix development. Don't hesitate to drop in for a chat at Helix community Helix Space :smile:
I think it's worth looking at the-way for inspiration.
While all these snippets managers are nice, I think they should be implemented as a plugin.
Regarding an eventual built-in support
It could be helpful to have simple built-in snippet support like vscode snippet:). Perhaps we can have a go at this?
edit: I did have a go that (#1178), aiming to support LSP snippet. It's far from complete but now we at least know what difficulties we might encounter if we eventually try to implement snippet inside helix-core, and whether we should leave it to a plugin of some sort.
Strongly need this feature. are there any alternatives?
You can implement it and send us a PR?
Strongly need this feature. are there any alternatives?
Here's the way I did it:
- write a simple language server: https://github.com/quantonganh/snippets-ls
- create a snippet file
~/.config/helix/go-snippets.yaml:
main: |-
func main() {
$1
}
err: |-
if err != nil {
$1
}
- update the
~/.config/helix/languages.toml:
[[language]]
name = "go"
formatter = { command = "goimports"}
language-servers = ["gopls", "snippets-ls"]
[language-server.snippets-ls]
args = ["-config", "/Users/quantong/.config/helix/go-snippets.yaml"]
command="snippets-ls"
Hope it helps.
There is still one things bothering me right now about the snippet support: The snippets are previewed in the file rather than in the completion/documentation area of the editor. While tabbing through completion candidates this is rather distracting.
I don't know how hard this is to implement, but i at least wanted to let others know. But all in all the snippet support is shaping up to be very good, keep up the amazing work👍
- write a simple language server: https://github.com/quantonganh/snippets-ls
I'm looking through the spec for 3.17, though it might be something you can answer directly? do you know if there is a way to do a streaming response with the language server protocol? I switched to gRPC more easily handle composable snippets, and potentially programmatic snippets.
the former would be easy to handle, just build and replace prior to sending. The latter would be difficult, if not impossible, without bidirectional streaming.
Just to add another LSP that has Snippets created for Helix https://github.com/estin/simple-completion-language-server by @estin
Actually come to think of it, if all the community cares about is dynamic snippet support(vscode style snippets) I could create a fork of my project that swaps out grpc for another json RPC, and acts as a server just for helix.
This would allow direct use of vscode snippets, plus support for snippets made of snippets, which is missing from vscode
Support for VSCode snippets would be excellent!
On Mon, 28 Aug 2023 at 18:20, Joshua Ferguson @.***> wrote:
Actually come to think of it, if all the community cares about is dynamic snippet support(vscode style snippets) I could create a fork of my project that swaps out grpc for another json RPC, and acts as a server just for helix.
This would allow direct use of vscode snippets, plus support for snippets made of snippets, which is missing from vscode
— Reply to this email directly, view it on GitHub https://github.com/helix-editor/helix/issues/395#issuecomment-1696061681, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOVIG2ATTRXEJOGLMHTY7LXXTHM7ANCNFSM47S5TSFA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I believe it is important not to overly rely on LSP (Language Server Protocol) and instead give more control to developers. Each developer has a clear understanding of the syntax of the language they are using, but everyone has slightly different coding preferences. It would be beneficial to allow developers to configure their own code snippet suggestions through a configuration file.
If you need a simple snippet in the current version...
helix/config.toml
C-g = [
":insert-output echo 'if err != nil {\\n}'",
"move_line_up",
"open_below",
]
I'm sorry if I'm missing something here. Has snippet support not landed yet? Maybe I'm misunderstanding the docs, but shouldn't it be working according to them?
https://docs.helix-editor.com/configuration.html?highlight=snippet#editorlsp-section
Some snippet support has landed but not proper support, that will be https://github.com/helix-editor/helix/pull/9801
Some snippet support has landed but not proper support, that will be #9801
Thank you kindly!
I don't know if this would best go into a new issue, but auto expand support for snippets would be very nice. VSCode does not support it, but it is a game changer workflow wise.
#9801 fully implements the snippet system, but a subsequent PR would still need to be made to implement a snippet manager inside Helix.
So how exactly can I define snippets then? That does not seem to be described in the documentation.
a subsequent PR would still need to be made to implement a snippet manager inside Helix.
@UltraBlackLinux I've read that, but the way I've understood the other PR is that this should somehow be possible already, even if it might be cumbersome, and that a snippet manager might only make stuff more convenient.
So how exactly can I define snippets then? That does not seem to be described in the documentation.
The quickest way to have snippets in Helix right now would be to use a language server for snippets, like: https://github.com/estin/simple-completion-language-server
One additional benefit with that approach is that your snippets will also work in other editors like Zed.
A full blown snippet manager will most likely make things easier for beginners, but it kinda depends on maintainers and the language server approach is adequate for now in my opinion.
We do want a snippet manager in core IIRC. Pascal mentioned wanting to use it for https://github.com/helix-editor/helix/issues/1438 as a special form of snippet.
Folks, I noticed https://github.com/helix-editor/helix/pull/9801 got merged. Is that the snippet system / manager you are talking about? Sadly, the PR has no docs and I do not have the time to go through the code right now.
As previously mentioned, #9801 added support for snippet operations, but we don't support managing customs snippets in the editor itself, that needs to currently happen through a separate language server (for example https://github.com/estin/simple-completion-language-server).
Not having the power of LuaSnip/UltiSnips is actually the only thing holding me back from using helix. Things like being able to generate part of the snippet using the input of some tabstops are just something that doesn't work with language server snippets, but is really powerful (LuaSnips function node or UlitSnips python eval blocks). Would really love to see this feature happening 👍
Strongly need this feature. are there any alternatives?
Nowadays, devs are using hx-lsp to solve this problem.