-
Notifications
You must be signed in to change notification settings - Fork 200
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
Support for snippet based completion #50
Comments
Wow, such technology! Now, seriously thanks. I'll try to implement this. Ideally, It should use snippet.el, not yasnippet.el, but I never finished that refactoring... |
Curious, why is that? yasnippet is your package so you obviously know, but I've never even heard of snippet.el |
Nothing special. It's just that yasnippet is way too bloated with stuff that eglot users might not care about, such as menus and snippet-organization logic. So a few years ago I started writing snippet.el from scratch in that repository. It's the snippet expansion and navigation core of yasnippet rewritten in good elisp. It's workable already but is missing the final stretch that would make it a library that yasnippet could use. And if it existed, eglot should use that.
Not quite. Though technically I rewrote every line, it's initially @pluskid's package. @npostavs is the new maintainer now. |
* eglot.el (eglot-client-capabilities): Declare support for snippet-based completions. (eglot-completion-at-point): Expand snippet completions with YASnippet if that is found.
@amol-mandhane, can you test the newest version? |
I'm using vue mode with vue-language-server. I can't seem to trigger
It has an |
GaryO <[email protected]> writes:
It has an insertText snippet with format 2, which is right, and then
yasnippet lets me fill in the args. Does eglot send
completionItem/resolve?
It does, but not in this particular context. It is something that needs
to be fixed in Eglot. I'll have a look, shouldn't be terribly hard.
Do you have the rest of the log? Actually only the immediately
preceding textDocument/completion request and response, if you can.
Thanks,
João
|
It was already used to resolve documentation bits of completions, but it can also be useful to resolve snippet templates and such. To resolve a completion, you need some part of a completion to start with. If it has a :data field exists and the server supports :resolveProvider, fetch the new object, otherwise use whatever we had already. * eglot.el (eglot-completion-at-point): Add another local function for resolving completions.
@garyo , this is a totally "blind" since I very much want to avoid installing that Vue thing as much as I can :-). So I created a new branch and did a commit there which you should test. Maybe it fixes your issue. If it doesn't we'll iterate until it does. |
Progress -- I now get snippets in a pure typescript buffer. Per your other message, I already had yasnippet and yas-global-mode set up, and I can confirm eglot is telling the server it supports snippets. Also, the log above is actually from a typescript (jsts-ls) server (my mistake, sorry), and with your patch eglot is working fine with that server now. I guess vetur/vls doesn't support function completion snippets though. I don't have them working with
And, I just tested vls in VS Code: same thing. The "special" vue snippets work there (as they do now with your patch in eglot), but no snippets on function completion. So I think your patch in your scratch branch is fine! |
So if I understand correctly the semi-blind untested
Cool! |
Yes, it's working for me! |
It was already used to resolve documentation bits of completions, but it can also be useful to resolve snippet templates and such. To resolve a completion, you need some part of a completion to start with. If it has a :data field exists and the server supports :resolveProvider, fetch the new object, otherwise use whatever we had already. * eglot.el (eglot-completion-at-point): Add another local function for resolving completions.
It was already used to resolve documentation bits of completions, but it can also be useful to resolve snippet templates and such. To resolve a completion, you need some part of a completion to start with. If it has a :data field exists and the server supports :resolveProvider, fetch the new object, otherwise use whatever we had already. * eglot.el (eglot-completion-at-point): Add another local function for resolving completions.
* eglot.el (eglot-client-capabilities): Declare support for snippet-based completions. (eglot-completion-at-point): Expand snippet completions with YASnippet if that is found. (eglot-note, eglot-warning, eglot-error): Diagnostic overlay priorities have to be slightly lower than yasnippet's, which must be reasonably high.
It was already used to resolve documentation bits of completions, but it can also be useful to resolve snippet templates and such. To resolve a completion, you need some part of a completion to start with. If it has a :data field exists and the server supports :resolveProvider, fetch the new object, otherwise use whatever we had already. * eglot.el (eglot-completion-at-point): Add another local function for resolving completions.
* eglot.el (eglot-client-capabilities): Declare support for snippet-based completions. (eglot-completion-at-point): Expand snippet completions with YASnippet if that is found. (eglot-note, eglot-warning, eglot-error): Diagnostic overlay priorities have to be slightly lower than yasnippet's, which must be reasonably high.
It was already used to resolve documentation bits of completions, but it can also be useful to resolve snippet templates and such. To resolve a completion, you need some part of a completion to start with. If it has a :data field exists and the server supports :resolveProvider, fetch the new object, otherwise use whatever we had already. * eglot.el (eglot-completion-at-point): Add another local function for resolving completions.
* eglot.el (eglot-client-capabilities): Declare support for snippet-based completions. (eglot-completion-at-point): Expand snippet completions with YASnippet if that is found. (eglot-note, eglot-warning, eglot-error): Diagnostic overlay priorities have to be slightly lower than yasnippet's, which must be reasonably high. #50: joaotavora/eglot#50
It was already used to resolve documentation bits of completions, but it can also be useful to resolve snippet templates and such. To resolve a completion, you need some part of a completion to start with. If it has a :data field exists and the server supports :resolveProvider, fetch the new object, otherwise use whatever we had already. * eglot.el (eglot-completion-at-point): Add another local function for resolving completions. #50: joaotavora/eglot#50
* eglot.el (eglot-client-capabilities): Declare support for snippet-based completions. (eglot-completion-at-point): Expand snippet completions with YASnippet if that is found. (eglot-note, eglot-warning, eglot-error): Diagnostic overlay priorities have to be slightly lower than yasnippet's, which must be reasonably high. GitHub-reference: close joaotavora/eglot#50
It was already used to resolve documentation bits of completions, but it can also be useful to resolve snippet templates and such. To resolve a completion, you need some part of a completion to start with. If it has a :data field exists and the server supports :resolveProvider, fetch the new object, otherwise use whatever we had already. * eglot.el (eglot-completion-at-point): Add another local function for resolving completions. GitHub-reference: per joaotavora/eglot#50
LSP servers support snippet based completion which can insert template arguments of the functions while completion.
Example of snippet based completion: https://i.stack.imgur.com/4gKHP.gif
The capability of snippet completion can be registered by setting TextDocumentClientCapabilities.completion.completionItem.snippetSupport to true, which is false by default.
Whether the completion item is plaintext or snippet is given by CompletionItem.kind field.
Yasnippet can be used to manage completion snippets. The support can be conditionally enabled if user has yasnippet installed so that package doesn't have hard dependency on yasnippet.
The text was updated successfully, but these errors were encountered: