In this tutorial i'll show you how to install language server on vim/nvim.
1. Firstly, you need to install the ccls
sudo pacman -S ccls or sudo apt install ccls.
2. Install coc.nvim
Inside vim config(put this following line inside .vimrc or ~/.config/nvim/init.vim).
Plug 'neoclide/coc.nvim', {'branch': 'release'}
3. Set coc.nvim configuration
Open vim, go to insert mode(press esc) and type :CocConfig, then a popup file will be shown and then copy paste the following script:
{
"languageserver": {
"ccls": {
"command": "ccls",
"filetypes": ["c", "cc", "cpp", "c++", "objc", "objcpp"],
"rootPatterns": [".ccls", "compile_commands.json", ".git/", ".hg/"],
"initializationOptions": {
"cache": {
"directory": "/tmp/ccls"
}
}
}
}
}
4. Here's some of the features you can try:
- Tab for completion
-
<cr>to choose first completion item -
gdto jump to definition -
grfor references -
gyfor type definition -
Kfor documentation -
<leader>rnfor renaming -
if,icfor func/class selection in visual mode -
<space>ato list diagnostics -
[g and ]gto go prev/next in diagnostics
Top comments (0)