Search code examples
c++neovim

Lazyvim/Neovim Formatting Issue upon saving: A space is required between consecutive right angle brackets (use '> >') (fix available) clang


In my LazyVim/NeoVim setup, everytime I save a file, my files are formatted.

Using Mason, I installed clangd LSP and clangd-format. Unfortunately, it always removes the space between consecutive >, which does not allow my Makefile to compile my code. I'm working in C++98 for a school project. As I understand, this is a necessity in code pre C++11, yet the formatter keeps removing this space.

I have been looking for a fix here: https://github.com/clangd/clangd but cannot seem to locate a sort of config file where I could change this option.


Solution

  • Managed to solve this pesky issue. Here are steps below!

    1. navigate to project root directory
    2. launch this cmd: clang-format -style=file -dump-config > .clang-format (you might need to install llvm with brew (MacOS): brew install llvm)
    3. enter .clang-format, replace the line Standard: Latest to Standard: C++03