kota's memex

https://clangd.llvm.org/installation.html

Often packaged as clang-tools. To understand your source code, clangd needs to know your build flags. (This is just a fact of life in C++, source files are not self-contained). By default, clangd will assume your code is built as clang some_file.cc, and you’ll probably get spurious errors about missing #included files, etc. There are a couple of ways to fix this:

compile_commands.json

This file provides compile commands for every source file in a project. It is usually generated by tools. Clangd will look in the parent directories of the files you edit looking for it.

cmake

For cmake you can generate this file by adding this flag: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1

compile_commands.json will be written to your build directory. You should symlink it (or simply copy it) to the root of your source tree, if they are different: ln -s ~/myproject/compile_commands.json ~/myproject-build/

bear

For non-cmake projects you can setup bear: https://github.com/rizsotto/Bear Make based projects are really easy: make clean; bear -- make

ccls also requires the compile_commands.json file, but has some more examples on their wiki: https://github.com/MaskRay/ccls/wiki/Project-Setup

compile_flags.txt

If all files in a project use the same build flags, you can put those flags one-per-line in compile_flags.txt in your source root. Creating this file by hand is a reasonable place to start if your project is quite simple.