Skip to content

Commit

Permalink
Recognize .C and .H as supported cpp extensions (zed-industries#21647)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Tripp <[email protected]>
  • Loading branch information
budde25 and notpeter authored Dec 11, 2024
1 parent c255e55 commit 28faba1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/languages/src/cpp/config.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
10 changes: 10 additions & 0 deletions docs/src/languages/c.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 28faba1

Please sign in to comment.