操作系统:Ubuntu20.40
。
curl -sL install-node.now.sh | bash
npm
安装neovim
和yarn
:sudo npm i --registry https://registry.npm.taobao.org install -g neovim yarn
npm config set registry https://registry.npm.taobao.org
Plug 'neoclide/coc.nvim', {'branch': 'release'}
:w
:source %
PlugInstall
coc.nvim
服务状态::checkhealth
:CocList extensions
。可采用模糊搜索方法选中安装的插件,之后按Tab
对插件进行处理。:CocInstall
:CocConfig
coc.nvim
子插件商城::CocInstall coc-marketplace
markdown
子插件:
:coc-marketplace
查询插件::CocList marketplace markdown
coc-markdownlint
::CocInstall coc-markdownlint
coc.nvim
提供的更方便的方式安装插件(推荐)
g:coc_global_extensions
。 let g:coc_global_extensions = [
\ 'coc-marketplace',
\ 'coc-json',
\ 'coc-vimlsp',
\ 'coc-markdownlint',
\ 'coc-sh',
\ 'coc-pyright',
\ 'coc-yaml',
\ 'coc-tabnine',
\ 'coc-translator',
\ 'coc-snippets',
\ 'coc-java',
\ 'coc-java-intellicode',
\ 'coc-xml',
\]
vim(nvim)
,命令模式下输入:CocConfig
进行配置。也可以编辑默认目录下的文件~/.config/nvim/coc-settings.json
。{
"coc.preferences.extensionUpdateCheck": "daily",
"suggest.noselect": true,
"suggest.enablePreselect": false,
"suggest.autoTrigger": "always",
"suggest.timeout": 5000,
"suggest.enablePreview": true,
"suggest.floatEnable": true,
"suggest.detailField": "preview",
"suggest.snippetIndicator": "",
"suggest.triggerCompletionWait": 100,
"suggest.echodocSupport": true,
"suggest.completionItemKindLabels": {
"class": "\uf0e8",
"color": "\ue22b",
"constant": "\uf8fe",
"default": "\uf29c",
"enum": "\uf435",
"enumMember": "\uf02b",
"event": "\ufacd",
"field": "\uf93d",
"file": "\uf723",
"folder": "\uf115",
"function": "\u0192",
"interface": "\uf417",
"keyword": "\uf1de",
"method": "\uf6a6",
"module": "\uf40d",
"operator": "\uf915",
"property": "\ue624",
"reference": "\ufa46",
"snippet": "\ue60b",
"struct": "\ufb44",
"text": "\ue612",
"typeParameter": "\uf728",
"unit": "\uf475",
"value": "\uf89f",
"variable": "\ue71b"
},
"diagnostic.errorSign": "\uf467",
"diagnostic.warningSign": "\uf071",
"diagnostic.infoSign": "\uf129",
"diagnostic.hintSign": "\uf864",
"diagnostic.displayByAle": false,
"diagnostic.refreshOnInsertMode": false,
"diagnostic.checkCurrentLine": true,
"diagnostic.virtualTextPrefix": " ❯❯❯ ",
"diagnostic.virtualText": true,
"codeLens.enable": true,
"list.previewHighlightGroup": "Statement",
// 保存时调整格式
"coc.preferences.formatOnSaveFiletypes": [
"javascript",
"typescript",
"html",
"css",
"json",
"java",
"python",
"vue",
"c",
"cpp",
"markdown",
"lua",
"bash"
],
"snippets.ultisnips.directories": [
"$HOME/.vim/plugged/vim-snippets/UltiSnips"
],
"coc.preferences.snippetStatusText": "Ⓢ ",
"python.formatting.provider": "black",
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/usr/lib/jvm/java-17-openjdk-amd64"
},
{
"name": "JavaSE-1.8",
"path": "/usr/lib/jvm/jdk1.8.0_202/bin/java",
"default": true
}
],
"languageserver": {
"bash": {
"command": "bash-language-server",
"args": [
"start"
],
"filetypes": [
"sh"
]
}
},
"yaml.format.enable": true
}
注:
java
遇到Error: The "java" server crashed xxx times in the last xxx minutes. The server will not be restarted
错误时,参看coc-java
的github上面提到的解决方法jdk版本与jdt语言服务器版本适配问题。