关于vim安装coc.nvim的步骤,可使用vim-plug,请自行查阅官方文档。ccls是用于c/c++/object c的language server,下面说说ccls的编译和安装html
1. git clone --depth=1 --recursivehttps://github.com/MaskRay/ccls 2. cd ccls 3. # Download "Pre-Built Binaries" from https://releases.llvm.org/download.html and unpack to /path/to/clang+llvm 4. cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_PREFIX_PATH=/path/to/clang+llvm 5. sudo cmake --build Release --target install
注意:c++
- 这里推荐的编译器是clang++而非默认的编译器是由于在github上有issue,推荐使用clang++。
- 安装好ccls以后,应该能在/usr/local/bin/目录下看到ccls这个文件
安装完成后,首先进入nvim中,而后输入<span style="color:red">:CocConfig</span>(注意这是一个vim命令,不要忽略前面的冒号),而后终端会出现一个新的页面,把下面的json文本粘贴进去(ctrl+shift+v)git
{ "languageserver": { "ccls": { "command": "ccls", "filetypes": ["c", "cpp", "cuda", "objc", "objcpp"], "rootPatterns": [".ccls-root", "compile_commands.json"], "initializationOptions": { "cache": { "directory": ".ccls-cache" }, "client": { "snippetSupport": true } } } } }
如今应该能够实现补全和检错了,具体的配置还须要自行去官网查阅文档,本文全部内容都能在官网找到:https://github.com/MaskRay/ccls/wikigithub