Clangd Hot-Update Compilation database

Clangd depends on compilation database/commands that in most cases is generated by build system generators like CMake.
but the build system listings are a part of project and may change very frequently in Just-created projects that are in heavy develop.

in such a condition, some editors like VSCode must reload to take this changes in account and this is annoying…

Yes unfortunately this is a known limitation we’ve been wanting to work on for a while now. There are also
[Feature Request] Watch for changes in "compile_commands.json" and "compile_flags.txt" · Issue #83 · clangd/clangd · GitHub and [Feature Request] Add a command to force clangd to reparse the compilation database · Issue #192 · clangd/clangd · GitHub as related issues.

We are planning to work on watching for changed files this quarter, at least to rebuild diagnostics on source files whenever you change headers those source files depend on. So at least there will be some infrastructure ready for basing this on top of and make this easier to solve.

I imagined a custom protocol message that tells to server that: Hey, Compilation situation has changed! reload the compilation DB again…

there’s already a notification in lsp protocol for reporting file changes, Redirecting… so this doesn’t need to be an extension.

I really hate VSCode C/C++ extension. it is so slow. but reacts very good.
beside to this, i’m a fanatic of clang/llvm.

I Hope clangd replace this extension completely…

See also https://reviews.llvm.org/D49267

1 Like