This is a demo Bazel project to show one case where LSP server (clangd) fails to work with the compile_commands.json
generated by the tool https://github.com/hedronvision/bazel-compile-commands-extractor.
The project imports https://github.com/modatwork/bazel-example-lib as a dependency. But clangd fails to parse the source code in the dependency.
The following steps are tested on macOS 13.5.2, clangd 18.1.1 and bazel 6.3.2.
# get the source code
git clone https://github.com/modatwork/bazel-example.git
cd bazel-example
git checkout v0.1.0
# first build the project
bazel build bar
# generate the compile_commands.json
bazel run :refresh_compile_commands
vim bar.cc
After jumping to the definition of add
function the LSP server complains that Failed to find compilation database for /Users/moda/.cache/bazel/b92409a607afcdd077412f77b2f754f6/external/foo/foo.h\n"
.
There is a compile_commands.json
file in the bazel-example
directory which has compile command for "external/foo/foo". But it's not used by clangd.