I found a relatively quick way to setup vim / neovim as an IDE for C++. Here is how it works.
- vim loads a plugin called Coc (I pronounce it coque which is a family-friendly approach).
- Coc runs a nodejs process to perform runtime checks.
- This process starts a configured language server (such as ccls or clangd) and then communicates with it.
Here is what we need to set it up.
- Install ccls.
- Configure ccls by using a .ccls file at the root of the project, or by generating a compile_commands.json file as with the set(CMAKE_EXPORT_COMPILE_COMMANDS on) option.
- Install a relatively new version of nodejs (I installed 16.14.0 LTS).
- curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
- sudo bash nodesource_setup.sh
- sudo apt install nodejs
- Install the Plug plugin management system in vim.
- curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
- Edit .vimrc to add the neoclide/coc plugin, the long list of key bindings from coc for convenience, and then reopen vim, running the command :PlugInstall.
- Configure coc using :CocConfig and editing the JSON that shows up. Refer here.
- Open a C++ source file in your project in vim / neovim.
No comments:
Post a Comment