Closed Jarred-Sumner closed 3 years ago
It does not support that feature.
You could report it at https://github.com/theia-ide/typescript-language-server if it isn't already but the chances of it being done are pretty slim.
The good news is that MS should come up with an official server soonish that will hopefully support that and more.
Thanks for opening up this issue. In short, yes it is possible.
For a long time I thought that this was a language server issue(turned out to be a LSP client bug) because the spec said:
By default the request can only delay the computation of the detail and documentation properties.
But now I read the spec and the next sentence is:
Since 3.16.0 the client can signal that it can resolve more properties lazily. This is done using the completionItem#resolveSupport client capability which lists all properties that can be filled in during a ‘completionItem/resolve’ request. All other properties (usually sortText, filterText, insertText and textEdit) must be provided in the textDocument/completion response and must not be changed during resolve.
The theia typescirpt language server will send back additionalTextEdits
but only after the completion item is resolved.
LSP for ST3 used to apply additional text edits only after resolving completion items, but I guess that was changed because some servers didn't support resoling completion items (If i recall correctly, those additional edits didn't get applied in that case, but I am not sure now).
So now(LSP in ST4) we apply additional text edits before resolving completion items,
which is also not ideal, because some servers will send additionalTextEdits
only after the completion item is resolved.
This is a bit complicated. The spec says:
By default the request can only delay the computation of the detail and documentation properties. Since 3.16.0 the client can signal that it can resolve more properties lazily. This is done using the completionItem#resolveSupport client capability which lists all properties that can be filled in during a ‘completionItem/resolve’ request. All other properties (usually sortText, filterText, insertText and textEdit) must be provided in the textDocument/completion response and must not be changed during resolve.
We don't announce support for completionItem#resolveSupport
so, in theory, we shouldn't expect that the additionalTextEdits
will be added on resolve.
But since this is a client capability, it's a bit of a gray area on what to expect from servers that were made before the 3.16.0 version of the spec was even out.
So if we follow the spec and add completionItem#resolveSupport
with a additionalTextEdits
value then we can resolve completion "according to the law".
But the problem is that I probably wouldn't want my completions to get delayed by resolve request. Ideally, that would happen on completion being highlighted in the popup but unfortunately, ST doesn't provide an API that would make that possible.
Yep, theia-ide/typescript-language-server does not respect client capabilities. cc @DonnieWest
Off the top of my head, probably the biggest blocker here is simply updating theia-ide/typescript-language-server
to the latest spec version. Last I looked into it, it was a bit hairy to upgrade the required libraries. It's something I'll add to my TODO list
Currently, LSP will show modules from other files, but it won't import them when you press enter.
If you click "code actions" it will offer to add the import for you.
With Visual Studio Code, the experience looks like this:
When I press enter, it inserts the import at the top of the file:
Is there a way to get LSP-typescript to behave similarly to Visual Studio Code on this? Visual Studio Code's way is more productive