Code snippets as LSP completions instead of snippets.json
I have checked that this feature is not already implemented
- [X] This feature does not exist
Use case
Including code snippets in the code completion responses instead of using vscode-extension specific snippets.json would make ruby-lsp feature directly available to other editors.
Description
I'm currently integrating ruby-lsp with Nova editor and initially was surprised to not see snippets in the code completion from my extension while they were available in vscode, until I found that these came from the extension's snippets.json and not from ruby-lsp
I think it would make sense to have as many features as possible that are supported by LSP already to be available through the lsp server so that all editors benefit from these extended capabilities.
Implementation
(up to you)
Thank you for the feature suggestion!
When you say serve completions from the server, do you mean method completions?
If yes, we already support completion for require paths and constants, but finalizing method support is tracked in https://github.com/Shopify/ruby-lsp/issues/899 (which means we can close this issue as a duplicate to centralize all discussions there).
If that's not what you mean, can you please elaborate?
Method completions are definitely needed. However, the snippets are rarely methods completions - as they are simple definitions and whole block structures (if you look into snippets.json ).
A low effort implementation could just respond with all the snippets via the LSP completion response. This already would move the existing functionality from the vscode-only side to the LSP server side and make them available to all editor integrations that use ruby-lsp.
A better implementation would of course try to only serve snippets that are valid or make sense in the current completion context of the edited document.
This makes sense to me. Here's the relevant part of the spec:
* Client supports snippets as insert text.
*
* A snippet can define tab stops and placeholders with `$1`, `$2`
* and `${3:foo}`. `$0` defines the final tab stop, it defaults to
* the end of the snippet. Placeholders with equal identifiers are
* linked, that is typing in one will update others too.
*/
snippetSupport?: boolean
Oh, I see what you mean now. Yeah, we can definitely move these to the server.
This issue is being marked as stale because there was no activity in the last 2 months