Neovim for C/C++ development

Neovim is a great productivity tool for working with C and C++ codebases — when properly configured and using some plugins, of course! Here’s how I configure neovim with clangd, vim-plugin, node-js, and other components that may need to be installed or updated.

Installing prerequisite packages

Here are some of the required third-party packages you may have to install:

$ sudo apt install ninja-build gettext libtool libtool-bin autoconf automake cmake pkg-config unzip curl

Updating gcc on your Linux machine

I’m currently using Linux Mint 19.3 on my development machine (I know, it’s a bit outdated, but it’s rock solid, and I haven’t found a compelling reason to updgrade), and it has version 7.4 of the gcc compiler installed. Here’s how I upgraded to the latest compiler version and configured it for the default compiler selection:

$ apt-cache search gcc  

$ sudo apt-get install gcc-8 g++-8

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 20 --slave /usr/bin/g++ g++ /usr/bin/g++-8

$ gcc --version
gcc (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0  <2>
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Use apt-cache search to list all available versions of the software compatible with your Linux system — For my system, this is version *8.4*

Use update-alternatives to configure the system to use the newly-installed version of gcc and g++.

Lastly, verify that the system uses the newly-installed version of gcc and g++ with gcc --version.

Installing node.js:

Let’s begin with cloning the node.js git repo and build and installing the binaries:

$ cd ~/devel
$ git clone https://github.com/nodejs/node.git
$ cd node
$ ./configure 
$ make -j4
$ make test-only          
$ sudo make install        

Run node on the terminal to verify the version:

$ node
Welcome to Node.js v17.0.0-pre.
Type ".help" for more information
> .exit