更改

添加2,417字节 、 2021年5月2日 (日) 00:53
建立内容为“{{lowercase}} [https://github.com/neoclide/coc.nvim coc.nvim](Conquer of Completion)是一个自动补全的框架,依赖 nodejs。 == 自动补全 ==…”的新页面
{{lowercase}}

[https://github.com/neoclide/coc.nvim coc.nvim](Conquer of Completion)是一个自动补全的框架,依赖 nodejs。

== 自动补全 ==

对不同语言的支持和配置方式见 [https://github.com/neoclide/coc.nvim/wiki/Language-servers Language servers]。

=== 通用的 language server ===

安装扩展 [https://github.com/iamcco/coc-diagnostic/ coc-diagnostic]。如 shell:<ref>https://github.com/meatwallace/dotfiles/issues/129#issuecomment-560035270</ref>
<syntaxhighlight lang=json>
"diagnostic-languageserver.filetypes": {
"sh": "shellcheck",
"PKGBUILD": "pkgbuildcheck"
},
"diagnostic-languageserver.formatFiletypes": {
"sh": "shfmt"
},
"diagnostic-languageserver.formatters": {
"shfmt": {
"command": "shfmt",
"args": ["-i", "4", "-ci"]
}
}
</syntaxhighlight>

定义新的 linter 可参照已有的 [https://github.com/iamcco/diagnostic-languageserver/wiki/Linters Linters]。如用于 PKGBUILD 的:<ref>[https://github.com/iamcco/diagnostic-languageserver/wiki/Linters#shellcheck linter shellcheck]</ref>
<syntaxhighlight lang=json>
"diagnostic-languageserver.linters": {
"pkgbuildcheck": {
"command": "shellcheck",
"debounce": 100,
"args": [
"--shell=bash", "--exclude=SC2034,SC2154,SC2164",
"--format", "json", "-"
],
"sourceName": "shellcheck",
"parseJson": {
"line": "line",
"column": "column",
"endLine": "endLine",
"endColumn": "endColumn",
"message": "${message} [${code}]",
"security": "level"
},
"securities": {
"error": "error",
"warning": "warning",
"info": "info",
"style": "hint"
}
}
},
</syntaxhighlight>

== 扩展 ==

可以为 coc.nvim 安装扩展(extension)

:CocInstall coc-json

=== coc-word ===

补全常见英文单词,包括在 [https://github.com/neoclide/coc-sources coc-sources] 中。

只对几个文件类型开启:<code>"coc.source.word.filetypes": ["text", "markdown", "html", "gitcommit", "mail", "nroff", "tex", ""],</code> <ref>[https://github.com/neoclide/coc.nvim/issues/1183#issuecomment-569338890 issue #1183, jrwrigh's comment]</ref>

=== [https://github.com/fannheyward/coc-rust-analyzer coc-rust-analyzer] ===

== 参考资料 ==

<references />

[[Category:Vim]]