Skip to content

Commit

Permalink
clangd fixes (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
garymm committed Sep 13, 2023
1 parent a5361cd commit cd09938
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
9 changes: 9 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -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]

3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
}
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 cd09938

Please sign in to comment.