From 28faba12a2799ef535aaf3158f7437f70ff523c8 Mon Sep 17 00:00:00 2001 From: Ethan Budd Date: Tue, 10 Dec 2024 18:55:21 -0600 Subject: [PATCH] Recognize .C and .H as supported cpp extensions (#21647) Co-authored-by: Peter Tripp --- crates/languages/src/cpp/config.toml | 2 +- docs/src/languages/c.md | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/languages/src/cpp/config.toml b/crates/languages/src/cpp/config.toml index e78bc8ea6c..6aba8727f3 100644 --- a/crates/languages/src/cpp/config.toml +++ b/crates/languages/src/cpp/config.toml @@ -1,6 +1,6 @@ name = "C++" grammar = "cpp" -path_suffixes = ["cc", "hh", "cpp", "h", "hpp", "cxx", "hxx", "c++", "ipp", "inl", "cu", "cuh"] +path_suffixes = ["cc", "hh", "cpp", "h", "hpp", "cxx", "hxx", "c++", "ipp", "inl", "cu", "cuh", "C", "H"] line_comments = ["// ", "/// ", "//! "] autoclose_before = ";:.,=}])>" brackets = [ diff --git a/docs/src/languages/c.md b/docs/src/languages/c.md index ce4a27a412..81e89baa5c 100644 --- a/docs/src/languages/c.md +++ b/docs/src/languages/c.md @@ -14,6 +14,16 @@ CompileFlags: Add: [-xc] ``` +By default clang and gcc by will recognize `*.C` and `*.H` (uppercase extensions) as C++ and not C and so Zed too follows this convention. If you are working with a C-only project (perhaps one with legacy uppercase pathing like `FILENAME.C`) you can override this behavior by adding this to your settings: + +```json +{ + "file_types": { + "C": ["C", "H"] + } +} +``` + ## Formatting 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: