Skip to content

Commit

Permalink
clangd fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
garymm committed Sep 12, 2023
1 parent a5361cd commit 78a5082
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://clangd.llvm.org/config
CompileFlags:
# Our toolchain wraps clang in a script, and clangd's system include extractor treats
# the output of that script differently just based on the file name. We
# replace the path to the script with the path to the actual clang binary so that
# clangd parses the output correctly.
Compiler: external/llvm_toolchain_files/bin/clang
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"files.watcherExclude": {
".cache/**": true,
"bazel-*/**": true,
"external/**": true
},
"clangd.arguments": [
"--header-insertion=never",
"--compile-commands-dir=${workspaceFolder}/",
"--query-driver=**"
"--query-driver=**",
"--enable-config"
],
"clangd.path": "${workspaceFolder}/external/llvm_toolchain_files/bin/clangd"
}
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Should work on Linux and MacOS.
* Install `bazel` or `bazelisk`

* Verify that you can build and test:
```
```sh
bazel test //...
```

Expand All @@ -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

Expand Down

0 comments on commit 78a5082

Please sign in to comment.