helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
32.72k stars 2.41k forks source link

snippet support #395

Open skewballfox opened 3 years ago

skewballfox commented 3 years ago

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 commented 3 years ago

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:

EpocSquadron commented 3 years ago

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

pppKin commented 2 years ago

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 commented 2 years ago

Strongly need this feature. are there any alternatives?

archseer commented 2 years ago

You can implement it and send us a PR?

quantonganh commented 1 year ago

Strongly need this feature. are there any alternatives?

Here's the way I did it:

main: |-
  func main() {
      $1
  }

err: |-
  if err != nil {
      $1
  }
[[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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

skewballfox commented 1 year ago

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 commented 1 year ago

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

zzx31584729 commented 7 months ago

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 commented 6 months ago

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 commented 4 months ago

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 commented 4 months ago

Some snippet support has landed but not proper support, that will be https://github.com/helix-editor/helix/pull/9801

victorz commented 4 months ago

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

Thank you kindly!

GameDungeon commented 1 month ago

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 commented 4 weeks ago

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