From b832837106b41e25f92e04536dba53f7d8df4320 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Tue, 9 Jul 2024 14:40:34 +0900 Subject: [PATCH] Meta: Add .clangd config file (with project-recommended defaults) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- .clangd | 6 ++++++ Documentation/EmacsConfiguration.md | 16 +++------------- Documentation/HelixConfiguration.md | 14 +------------- Documentation/NvimConfiguration.md | 12 +----------- Documentation/VSCodeConfiguration.md | 13 ------------- 5 files changed, 11 insertions(+), 50 deletions(-) create mode 100644 .clangd diff --git a/.clangd b/.clangd new file mode 100644 index 00000000000..b5e8fe31684 --- /dev/null +++ b/.clangd @@ -0,0 +1,6 @@ +CompileFlags: + CompilationDatabase: Build/ladybird + +Diagnostics: + UnusedIncludes: None + MissingIncludes: None diff --git a/Documentation/EmacsConfiguration.md b/Documentation/EmacsConfiguration.md index 03e1fd333fe..9f401e660f7 100644 --- a/Documentation/EmacsConfiguration.md +++ b/Documentation/EmacsConfiguration.md @@ -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 diff --git a/Documentation/HelixConfiguration.md b/Documentation/HelixConfiguration.md index 77d188362e6..feb2ff624e9 100644 --- a/Documentation/HelixConfiguration.md +++ b/Documentation/HelixConfiguration.md @@ -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" diff --git a/Documentation/NvimConfiguration.md b/Documentation/NvimConfiguration.md index a77d8ba2bc3..382fd19f4aa 100644 --- a/Documentation/NvimConfiguration.md +++ b/Documentation/NvimConfiguration.md @@ -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 diff --git a/Documentation/VSCodeConfiguration.md b/Documentation/VSCodeConfiguration.md index ead27edc5ee..81e5c7bdacb 100644 --- a/Documentation/VSCodeConfiguration.md +++ b/Documentation/VSCodeConfiguration.md @@ -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.