Skip to content

Commit

Permalink
Meta: Add .clangd config file (with project-recommended defaults)
Browse files Browse the repository at this point in the history
This change also removes parts of the existing docs that explain how to
create a .clangd file with the project-recommended  defaults. (Those
docs are no longer necessary — since this change adds a .clangd file to
the repo, containing those same defaults).
  • Loading branch information
sideshowbarker authored and ADKaster committed Jul 9, 2024
1 parent 65d8d20 commit b832837
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 50 deletions.
6 changes: 6 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CompileFlags:
CompilationDatabase: Build/ladybird

Diagnostics:
UnusedIncludes: None
MissingIncludes: None
16 changes: 3 additions & 13 deletions Documentation/EmacsConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@ Emacs can be configured with `lsp-mode` and `clangd` to work well.

### clangd

The official clangd extension can be used for C++ comprehension. You
can use the following `.clangd` file placed in the project root:
The official clangd extension can be used for C++ comprehension.

```yaml
CompileFlags:
CompilationDatabase: Build/ladybird

Diagnostics:
UnusedIncludes: None
MissingIncludes: None
```
Run cmake (`Meta/ladybird.sh run ladybird` or similar) at least once for this
to work, as it will generate the `Build/ladybird/compile_commands.json`
Run cmake (`Meta/ladybird.sh run ladybird` or similar) at least once for clangd
to work, as doing so will generate the `Build/ladybird/compile_commands.json`
that is needed by `clangd`.

### lsp-mode
Expand Down
14 changes: 1 addition & 13 deletions Documentation/HelixConfiguration.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# Helix Configuration
Helix comes with support for `clangd` and `clang-format` out of the box! However, a small bit of configuration is needed for it to work correctly with Ladybird.

The following `.clangd` should be placed in the project root:
```yaml
CompileFlags:
CompilationDatabase: Build/ladybird

Diagnostics:
UnusedIncludes: None
MissingIncludes: None
```
You also need to configure the clangd server to not insert headers improperly. To do this, create a `.helix/languages.toml` file in the project root:
Helix comes with support for `clangd` and `clang-format` out of the box! However, you also need to configure the clangd server to not insert headers improperly. To do this, create a `.helix/languages.toml` file in the project root:
```toml
[language-server.ladybird]
command = "clangd"
Expand Down
12 changes: 1 addition & 11 deletions Documentation/NvimConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,7 @@ project:
2. With [coc.nvim](https://github.com/neoclide/coc.nvim) (from scratch, potentially out of date)

For both setups, make sure you ran `./Meta/ladybird.sh run ladybird` at least
once. Additionally, clangd should be configured with the following (in the
`.clangd` file at the root of the project):

```yaml
CompileFlags:
CompilationDatabase: Build/ladybird

Diagnostics:
UnusedIncludes: None
MissingIncludes: None
```
once.

## With nvim-lspconfig

Expand Down
13 changes: 0 additions & 13 deletions Documentation/VSCodeConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@ Clangd has the best support for modern compilers, especially if configured as no
The official clangd extension can be used for C++ comprehension. It is recommended in general, as it is most likely to work on all platforms.

clangd uses ``compile_commands.json`` files to understand the project. CMake will generate these in Build/ladybird.
Depending on which configuration you use most, set the CompilationDatabase configuration item in the below ``.clangd`` file accordingly. It goes at the root of your checkout (``ladybird/.clangd``):

```yaml
CompileFlags:
CompilationDatabase: Build/ladybird

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/ladybird.sh run ladybird`` at least once to generate the ``compile_commands.json`` file.

Expand Down

0 comments on commit b832837

Please sign in to comment.