關於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