Documentation: Recommend disabling clangd's IncludeCleaner feature

This commit is contained in:
Andrew Kaster 2024-02-05 04:28:11 -07:00 committed by Andrew Kaster
parent e6762e8d4d
commit 713698d2ca
3 changed files with 15 additions and 0 deletions

View file

@ -15,6 +15,10 @@ CompileFlags:
- "-UNO_TLS"
- "-I/path/to/serenity/Toolchain/Local/x86_64/x86_64-pc-serenity/include/c++/13.1.0"
- "-I/path/to/serenity/Toolchain/Local/x86_64/x86_64-pc-serenity/include/c++/13.1.0/x86_64-pc-serenity"
Diagnostics:
UnusedIncludes: None
MissingIncludes: None
```
You will need to change `/path/to/serenity` and change `13.1.0` to

View file

@ -6,6 +6,10 @@ The following `.clangd` should be placed in the project root:
CompileFlags:
CompilationDatabase: Build/x86_64 # Or whatever architecture you're targeting, e.g. aarch64
Add: [-D__serenity__]
Diagnostics:
UnusedIncludes: None
MissingIncludes: None
```
You also need to configure the clangd server to detect headers properly from the Serenity toolchain. To do this, create a `.helix/languages.toml` file in the project root:

View file

@ -25,8 +25,15 @@ Depending on which configuration you use most, set the CompilationDatabase confi
CompileFlags:
Add: [-D__serenity__]
CompilationDatabase: Build/x86_64
Diagnostics:
UnusedIncludes: None
MissingIncludes: None
```
The UnusedIncludes and MissingIncludes flags are used to disable the [Include Cleaner](https://clangd.llvm.org/design/include-cleaner) feature of newer clangd releases.
It can be re-enabled if you don't mind the noisy inlay hints and problems in the problem view.
Run ``./Meta/serenity.sh run`` at least once to generate the ``compile_commands.json`` file.
In addition to the ``.clangd`` file, the ``settings.json`` file below has a required ``clangd.arguments`` entry for ``--query-driver`` that allows clangd to find the cross-compiler's built-in include paths.