From bce85757e476971c2916a9c72805e056b42155c2 Mon Sep 17 00:00:00 2001 From: Gary Miguel Date: Tue, 12 Sep 2023 12:50:34 -0700 Subject: [PATCH] clangd fixes --- .clangd | 9 +++++++++ .vscode/settings.json | 3 ++- README.md | 14 +++----------- 3 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 .clangd diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..07cd805 --- /dev/null +++ b/.clangd @@ -0,0 +1,9 @@ +# https://clangd.llvm.org/config +CompileFlags: + # clangd system includes extractor doesn't set -stdlib=libc++, + # even though we do when we actually compile, which results in + # incorrect system include paths. These fix that. + # Specifying non-existent include paths on other platforms doesn't cause issues + # (e.g. mentioning linux-gnu works on MacOS). + Add: [-nostdinc++, -isystem, external/llvm_toolchain_files/include/x86_64-unknown-linux-gnu/c++/v1, -isystem, external/llvm_toolchain_files/include/c++/v1] + diff --git a/.vscode/settings.json b/.vscode/settings.json index ffddb98..a40cebe 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,13 @@ { "files.watcherExclude": { + ".cache/**": true, "bazel-*/**": true, "external/**": true }, "clangd.arguments": [ "--header-insertion=never", "--compile-commands-dir=${workspaceFolder}/", - "--query-driver=**" + "--enable-config" ], "clangd.path": "${workspaceFolder}/external/llvm_toolchain_files/bin/clangd" } diff --git a/README.md b/README.md index a076cb8..ddb7f10 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Should work on Linux and MacOS. * Install `bazel` or `bazelisk` * Verify that you can build and test: -``` +```sh bazel test //... ``` @@ -22,22 +22,14 @@ Install the recommended extensions. See .vscode/extensions.json. Create a compilation database: ```sh -bazel build //... -bazel run @hedron_compile_commands//:refresh_all +bazel build //... && bazel run @hedron_compile_commands//:refresh_all ``` Then configure [clangd](https://clangd.llvm.org/). If you're using VS Code, the .vscode/settings does this for you, and .vscode/extensions.json already recommends installing the clangd extension. -Otherwise, set these clangd args: - -``` ---header-insertion=never ---compile-commands-dir=${workspaceFolder}/ ---query-driver=** -``` - +Otherwise, copy the clangd args from the [.vscode/settings.json](.vscode/settings.json). ## Status