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

Tsserver now provides snippet completion, does this unblock arg ghost-test in completions? #646

Closed
burgessa23 opened this issue Dec 13, 2021 · 5 comments

Comments

@burgessa23
Copy link

burgessa23 commented Dec 13, 2021

According to neovim/nvim-lspconfig#1259 tsserver supports snippet completion now. Does this mean that ghost-text for args can now work? Is there something that needs to be set in capabilities to get it working?

Apologies if I'm misunderstanding the issue.

Previously closed issue for reference:

The ghost text content is determined by the LSP server (or custom source).

For example, gopls will show the function arguments as ghost text. So it is depending on the your server. I can't support it in nvim-cmp. Sorry.

スクリーンショット 2021-11-10 3 59 52

Originally posted by @hrsh7th in #503 (comment)

@dmitmel
Copy link
Collaborator

dmitmel commented Dec 13, 2021

Looking at the linked pull request to the TS repository (microsoft/TypeScript#43149), I'm inclined to believe that there has been a misunderstanding here. TSServer currently implements snippet completions only for autoimports, and not for filling out function call parameters. Here's the closest I could find to a "tracking issue" for support of snippets in TSServer: microsoft/TypeScript#25207, and it says that "method completions are currently implemented by VSCode manually" (a look into the built-in VSCode extension for Typescript confirms that: 1, 2, 3). So yeah, right now typescript-language-server does, in fact, support snippets in completion, just not the kind of snippets you were hoping for.

@gegoune
Copy link
Contributor

gegoune commented Dec 13, 2021

@dmitmel Please ignore my ignorance, JS is a complicated ecosystem. I have seen this release a while ago and tried to set it up with no success. I am referring to second item on the list:

feat: add support for snippet completions for methods/functions (#303)

That's different to tsserver, isn't it? But isn't it what tsserver configuration from lspconfig uses?

@dmitmel
Copy link
Collaborator

dmitmel commented Dec 13, 2021

Oh, I think I have found the issue. The PR you mentioned, typescript-language-server/typescript-language-server#303, does implement this functionality, and typescript-language-server does return snippets for function calls if you set the setting completions.completeFunctionCalls, but it does so in the completionItem/resolve method, and not with the initial batch of completions requested in textDocument/completion. cc @hrsh7th: nvim-cmp should respond to updates of insertText in completionItem/resolve.

@burgessa23
Copy link
Author

Thanks @dmitmel

@hrsh7th
Copy link
Owner

hrsh7th commented Dec 14, 2021

Hm... The LSP spec seems to define the resolvable properties in capabilities.

OK. I'll add it.

mrnugget added a commit to zed-industries/zed that referenced this issue May 2, 2024
This allows function call (i.e. snippet) completion with
`typescript-language-server`. So far that didn't work, because
`typescript-language-server` doesn't respond with `insertText` when
getting the completions, but only when then sending
`completionItem/resolve` requests. See:
hrsh7th/nvim-cmp#646 (comment)

What this PR does is to support text edits in the response to
`completionItem/resolve`, which means updating the completion item.

It then enables this feature by default for
`typescript-language-server`.


TODOs:

- [x] Make this work over collab
- [x] Test that this doesn't break existing language server support
- [x] Refactor duplicated code

Release Notes:

- Added support for function call completion when using
`typescript-language-server`. This will result in parameters being
added, which can then be changed and navigated with `<tab>`. For this to
work with `typescript-language-server`, the documentation for a given
completion item needs to be resolved, meaning that if one types very
quickly and accepts completion before `typescript-language-server` could
respond with the documentation, no full function completion is used.

Demo:


https://github.com/zed-industries/zed/assets/1185253/c23ebe12-5902-4b50-888c-d9b8cd32965d
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

4 participants