How To Setup Clangd With GCC Headers and Neovim LSP for Competitive Programming

Michael Bao
Unixification
Published in
5 min readJan 8, 2023

--

Screenshot by author

I recently got frustrated with ccls because it was the only thing slowing down my blazingly fast Neovim experience. Don’t get me wrong it’s a great tool, however, the gripe I had with it is that it didn’t have single-file support, which… in competitive programming is almost always the case. Single-file support means that clangd or ccls won’t index anything. This was partially possible with ccls, however, indexing would still use an excessive amount of resources.

I have always desired to switch to clangd, but it usually just didn’t work or I got a weird error at the top of the document which with my OCD was unacceptable. I also did quite a bit of research about this topic, however, nothing really was complete (which is why I’m writing this).

For this configuration, I expect that you have a Neovim Lua config, but if you are using Vimscript the same should still apply. I am using an M1 Mac (which was why it was hard to find resources), but if you are using another device the same should apply.

Installation

You can skip the following if you have a working Neovim LSP config.

Install Neovim LSP and Clangd

--

--

Michael Bao
Unixification

Neovim | Arch Linux | macOS | I love to write about random tech stuff. Tinkering around with Linux, Neovim, and computers.