From 51e97d343da40750c5bd43c09396457715b9fc59 Mon Sep 17 00:00:00 2001 From: Peter Tripp Date: Wed, 26 Nov 2025 09:55:23 -0500 Subject: [PATCH] languages: Recognize .clangd as YAML (#43557) Follow-up to: https://github.com/zed-industries/zed/pull/43469 Thanks @WeetHet for [the idea]([WeetHet](https://github.com/WeetHet)). Release Notes: - Added support for identifying. .clangd files as YAML by default --- crates/languages/src/yaml/config.toml | 2 +- docs/src/languages/c.md | 1 + docs/src/languages/cpp.md | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/languages/src/yaml/config.toml b/crates/languages/src/yaml/config.toml index 8834b3205af810c26fc9a8835f1c2afe7a185d8c..51e8e1224a40904e0dfbb0204eb531e6b2664825 100644 --- a/crates/languages/src/yaml/config.toml +++ b/crates/languages/src/yaml/config.toml @@ -1,6 +1,6 @@ name = "YAML" grammar = "yaml" -path_suffixes = ["yml", "yaml", "pixi.lock", "clang-format"] +path_suffixes = ["yml", "yaml", "pixi.lock", "clang-format", "clangd"] line_comments = ["# "] autoclose_before = ",]}" brackets = [ diff --git a/docs/src/languages/c.md b/docs/src/languages/c.md index 565b0b5acbef78a23722020dcbad9300748dbb16..2259ad21a4afa69390ef7ef15bfa4bb96cf44e1e 100644 --- a/docs/src/languages/c.md +++ b/docs/src/languages/c.md @@ -11,6 +11,7 @@ C support is available natively in Zed. Clangd out of the box assumes mixed C++/C projects. If you have a C-only project you may wish to instruct clangd to treat all files as C using the `-xc` flag. To do this, create a `.clangd` file in the root of your project with the following: ```yaml +# yaml-language-server: $schema=https://json.schemastore.org/clangd.json CompileFlags: Add: [-xc] ``` diff --git a/docs/src/languages/cpp.md b/docs/src/languages/cpp.md index 36cdc7a9580d2de41a6eb7063d694d54c7caffa4..c20dd58335caca45a6923cc0527605d6cc4b5564 100644 --- a/docs/src/languages/cpp.md +++ b/docs/src/languages/cpp.md @@ -78,6 +78,7 @@ You can pass any number of arguments to clangd. To see a full set of available o By default Zed will use the `clangd` language server for formatting C++ code. The Clangd is the same as the `clang-format` CLI tool. To configure this you can add a `.clang-format` file. For example: ```yaml +# yaml-language-server: $schema=https://json.schemastore.org/clang-format-21.x.json --- BasedOnStyle: LLVM IndentWidth: 4 @@ -106,7 +107,8 @@ You can trigger formatting via {#kb editor::Format} or the `editor: format` acti In the root of your project, it is generally common to create a `.clangd` file to set extra configuration. -```text +```yaml +# yaml-language-server: $schema=https://json.schemastore.org/clangd.json CompileFlags: Add: - "--include-directory=/path/to/include"