这两个配置都可以在用户从 company 的候选项选择变量后自动 import 进来,标准 lsp-mode 做不到。它们是怎么做到的?
有没有试试 company-lsp ,但是 lsp-mode 不推荐用它了
?lsp不推荐用company lsp,那要做自动补全是咋办了呢
completion-at-point
按下面这个 commit, doom 已经把 company-lsp 去掉了。但是还能做动自动 import
https://github.com/hlissner/doom-emacs/commit/b3c957065c036ad677b21aafcea5f726c303d653
现在使用 company-capf 了
有个import-js的东西,是不是用了这个?
[Trace - 07:46:57 PM] Sending request 'completionItem/resolve - (1841)'.
Params: {
"insertTextFormat": 2,
"data": {
"entryNames": [
{
"source": "child_process",
"name": "fork"
}
],
"offset": 3,
"line": 49,
"file": "/Users/jadestrong/Documents/JadeStrong/lsp-test/index.ts"
},
"commitCharacters": [
".",
",",
"("
],
"sortText": "5",
"kind": 3,
"label": "fork"
}
[Trace - 07:46:57 PM] Received response 'completionItem/resolve - (1841)' in 18ms.
Result: {
"additionalTextEdits": [
{
"newText": "import { fork } from \"child_process\";\n",
"range": {
"end": {
"character": 0,
"line": 0
},
"start": {
"character": 0,
"line": 0
}
}
}
],
"detail": "Auto import from 'child_process'\nfunction fork(modulePath: string, args?: readonly string[] | undefined, options?: ForkOptions | undefined): ChildProcess",
"insertTextFormat": 2,
"data": {
"entryNames": [
{
"source": "child_process",
"name": "fork"
}
],
"offset": 3,
"line": 49,
"file": "/Users/jadestrong/Documents/JadeStrong/lsp-test/index.ts"
},
"commitCharacters": [
".",
",",
"("
],
"sortText": "5",
"kind": 3,
"label": "fork"
}
我还是用的 company-lsp , 看log的话,就是 lsp 补全的
VS Code 对于 TS 是有自动 import 的支持的。我写 TS 的时候是用 tide 而不是 lsp-mode,这个也是有自动 import 的功能的。不太熟 doom / spacemacs,可能它们也是用了 tide?
今天重新试了一下,最新版本的 doom 能够自动 import 是因为默认用 tide, 切换成 lsp 就不行了。company-lsp 也可以。感谢各位。 @jadestrong @yfzhe @lawrsp