| Summary: | [LSP plugin] Auto import feature not working for typescript-language-server | ||
|---|---|---|---|
| Product: | [Applications] kate | Reporter: | Arnaud <arnaud.vergnet> |
| Component: | general | Assignee: | KWrite Developers <kwrite-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 22.08.3 | ||
| Target Milestone: | --- | ||
| Platform: | Manjaro | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Arnaud
2022-11-27 18:18:36 UTC
I looked more into this and it seems Kate expects the LSP server to send the import text to insert in the additionalTextEdits key. (see https://invent.kde.org/utilities/kate/-/blob/master/addons/lspclient/lspclientcompletion.cpp#L506 and https://invent.kde.org/utilities/kate/-/blob/master/addons/lspclient/lspclientserver.cpp#L704) But typescript-language-server is not filling this key, instead it uses the data key to pass a more complex object (see the function asCompletionItem in https://github.com/typescript-language-server/typescript-language-server/blob/master/src/completion.ts). Here is an example of data sent by the server when showing the completion for a component named KateTestFunction: { "commitCharacters": [ ".", ",", "(" ], "data": { "entryNames": [ { "data": { "exportName": "KateTestFunction", "fileName": "/path/to/KateTestFunction.tsx", "moduleSpecifier": "./KateTestFunction" }, "name": "KateTestFunction", "source": "./KateTestFunction" } ], "file": "/path/to/KateTest.tsx", "line": 4, "offset": 20 }, "detail": "./KateTestFunction", "kind": 3, "label": "KateTestFunction", "sortText": "16" } So in this case, Kate should use the content of the response to generate the following text at the top of the file: import { KateTestFunction } from "./KateTestFunction"; Or insert the name in an already existing import statement: import { OtherFunction } from "./KateTestFunction"; => import { OtherFunction, KateTestFunction } from "./KateTestFunction"; I don't know much about Kate or LSP so maybe I'm wrong, but hopefully this helps understanding the issue. Compiled latest version from git and it seems fixed, thanks for your hard work! |