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 #678

Open
ismay opened this issue Mar 23, 2023 · 6 comments
Open

Snippet support #678

ismay opened this issue Mar 23, 2023 · 6 comments

Comments

@ismay
Copy link

ismay commented Mar 23, 2023

I have been looking into kak-lsp's snippet support. From the docs it seems like there should be support for snippets: https://github.com/kak-lsp/kak-lsp#snippets. In my configuration I've enabled snippet support with snippet_support = true.

Now I've tested this with the typescript language server in a javascript file. The ts language server is working as expected. I would expect common patterns like a for loop to be completed as a snippet, as can be seen in the vscode docs here for example: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_builtin-snippets. But that does not work with kak-lsp out of the box, all that happens is that the language server in kakoune suggests completing the for keyword.

The documentation on kak-lsp's snippet support is a little sparse. Should there be autocompletion via snippets for common language features like a for loop, a switch, etcetera? Does the user need to install these snippets themselves?

@sclu1034
Copy link
Contributor

What you've linked are snippets built into VSCode, while language servers are extensions. Unless the snippets are actually emitted as regular completion items by a language server, they would not exist in kak-lsp.

@ismay
Copy link
Author

ismay commented Mar 23, 2023

I see. So what exactly are the snippets alluded to in kak-lsp's documentation then? It's a little unclear to me what functionality kak-lsp's snippet capabilites are supposed to provide, if not the type of completions referred to in vscode's docs.

@krobelus
Copy link
Member

yeah snippets are supported (see 22b0602 for how they usually work) but we don't have VSCode's extra user-defined snippets. They need to come from the language server. With rust-analyzer there are lots of snippets.

user-defined snippets could go into a dedicated snippets plugin

@ismay
Copy link
Author

ismay commented Mar 23, 2023

yeah snippets are supported (see 22b0602 for how they usually work) but we don't have VSCode's extra user-defined snippets. They need to come from the language server. With rust-analyzer there are lots of snippets.

I see. So I guess then that the typescript language server just doesn't ship with a lot of snippets (as I don't think I've encountered any so far).

user-defined snippets could go into a dedicated snippets plugin

So you mean a plugin like https://github.com/occivink/kakoune-snippets for example? I'm assuming there's no way to supply user defined snippets that would somehow be picked up by kak-lsp (or the underlying language servers) right, you'd have to just use a separate plugin?

@krobelus
Copy link
Member

Ideally the the language server supplies snippets, then it works for all editors.

it's possible to add a new completer option that works like lsp_completions.
It's probably not ergonomic because you'd need to match a few implementation details.

@ismay
Copy link
Author

ismay commented Mar 25, 2023

Ok cool. Yeah then I'll just add snippets through the kakoune-snippets plugin. That sounds like the most ergonomic solution. Thanks for explaining!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants