-
Configure your [Neo]Vim to support Language Server Protocol -- I recommend (early 2020) coc.nvim.
-
Install ccls on your system.
-
Configure your LSP plugin in Vim to use
ccls
. In case ofcoc.nvim
, the configuration looks as follows:"languageserver": { "ccls": { "command": "ccls", "filetypes": [ "c", "cpp" ], "settings": {}, "rootPatterns": [ ".ccls", "compile_commands.json", ".vim/", ".git/", ".hg/" ], "initializationOptions": { "cache": { "directory": "/tmp/ccls" }, "highlight": { "lsRanges": true } }
-
Create a build folder and build the project using cmake:
$ mkdir build-vim $ cd build-vim $ cmake .. \ --preset mini \ -G Ninja \ -DCMAKE_TOOLCHAIN_FILE=../cmake/GccArmNoneEabi.cmake \ -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE \ -DGENERATE_BBF=YES ... and other cmake flags $ ninja
-
Locate a
compile_commands.json
file forccls
. By default,ccls
searches in project's root directory, butninja
produces it in the build folder. There are two options:- Update
ccls
config to letccls
know, that it should search for it in thebuild-vim
subfolder, or - make a symbolic link in project's root directory:
ln -s build-vim/compile_commands.json
.
- Update
-
Install some spell checker (optional but recommended).
-
Get to work! 💪