Skip to content
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

snippet support #395

Open
skewballfox opened this issue Jun 30, 2021 · 23 comments
Open

snippet support #395

skewballfox opened this issue Jun 30, 2021 · 23 comments
Labels
A-helix-term Area: Helix term improvements A-language-server Area: Language server client C-enhancement Category: Improvements

Comments

@skewballfox
Copy link

skewballfox commented Jun 30, 2021

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.

@CBenoit CBenoit added A-plugin Area: Plugin system C-enhancement Category: Improvements C-discussion Category: Discussion or questions that doesn't represent real issues labels Jun 30, 2021
@CBenoit
Copy link
Member

CBenoit commented Jun 30, 2021

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 😄

@EpocSquadron
Copy link
Contributor

I think it's worth looking at the-way for inspiration.

@pppKin
Copy link
Contributor

pppKin commented Oct 8, 2021

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.

@theowenyoung
Copy link

theowenyoung commented Jun 26, 2022

Strongly need this feature. are there any alternatives?

@archseer
Copy link
Member

You can implement it and send us a PR?

@kirawi kirawi added A-language-server Area: Language server client and removed A-plugin Area: Plugin system C-discussion Category: Discussion or questions that doesn't represent real issues labels Nov 28, 2022
@kirawi kirawi added the A-helix-term Area: Helix term improvements label Mar 26, 2023
@quantonganh
Copy link
Contributor

quantonganh commented Aug 9, 2023

Strongly need this feature. are there any alternatives?

Here's the way I did it:

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.

@Uldgiw
Copy link

Uldgiw commented Aug 27, 2023

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👍

@skewballfox
Copy link
Author

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.

@danillos
Copy link
Contributor

danillos commented Aug 28, 2023

Just to add another LSP that has Snippets created for Helix https://github.com/estin/simple-completion-language-server by @estin

@skewballfox
Copy link
Author

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

@erasebegin
Copy link

erasebegin commented Aug 28, 2023 via email

@zzx31584729
Copy link

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.

@janos-r
Copy link
Contributor

janos-r commented Mar 10, 2024

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",
]

@victorz
Copy link

victorz commented Apr 19, 2024

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

@gabydd
Copy link
Member

gabydd commented Apr 19, 2024

Some snippet support has landed but not proper support, that will be #9801

@victorz
Copy link

victorz commented Apr 20, 2024

Some snippet support has landed but not proper support, that will be #9801

Thank you kindly!

@CountingBeeps
Copy link

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.

@kirawi
Copy link
Member

kirawi commented Aug 12, 2024

#9801 fully implements the snippet system, but a subsequent PR would still need to be made to implement a snippet manager inside Helix.

@danrot
Copy link

danrot commented Jan 19, 2025

So how exactly can I define snippets then? That does not seem to be described in the documentation.

@UltraBlackLinux
Copy link

a subsequent PR would still need to be made to implement a snippet manager inside Helix.

@danrot
Copy link

danrot commented Jan 19, 2025

@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.

@zetashift
Copy link
Contributor

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.

@kirawi
Copy link
Member

kirawi commented Jan 19, 2025

We do want a snippet manager in core IIRC. Pascal mentioned wanting to use it for #1438 as a special form of snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements A-language-server Area: Language server client C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests