Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clangd fixes #80

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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