vscode-clangd icon indicating copy to clipboard operation
vscode-clangd copied to clipboard

Default .Clang-Format options

Open SwiftWinds opened this issue 3 years ago • 5 comments

In Microsoft's C/C++ extension, this is possible via the C_Cpp.clang_format_fallbackStyle setting. It'd be nice if clangd could have the same because it's annoying to configure a .Clang-Format for every project I make, especially for the small one-off projects that don't involve collaboration. Thank you for considering my request!

SwiftWinds avatar Apr 29 '21 07:04 SwiftWinds

I'm confused why this is named .Clang-Tidy when you are asking about clang-format. Anyway you can pass the command line flag --fallback-style=<> to provide a default formatting. AFAIK this only supports the built in styles(LLVM, Google, Mozilla, Webkit, GNU, Microsoft, Chromium or None).

njames93 avatar Apr 29 '21 08:04 njames93

Or put .clang-format in your home directory?

sam-mccall avatar Apr 29 '21 10:04 sam-mccall

I'm confused why this is named .Clang-Tidy when you are asking about clang-format. Anyway you can pass the command line flag --fallback-style=<> to provide a default formatting. AFAIK this only supports the built in styles(LLVM, Google, Mozilla, Webkit, GNU, Microsoft, Chromium or None).

My bad, I meant to write .Clang-Format! This would require putting the flag in the .vscode/compile_commands.json file for every project, no? Sorry, I'm new to this extension.

Or put .clang-format in your home directory?

Ah, that works. Thanks for the suggestion. :)

SwiftWinds avatar Apr 29 '21 20:04 SwiftWinds

Or put .clang-format in your home directory?

Ah, that works. Thanks for the suggestion. :)

I'm having the same issue, but in my case, placing .clang-format on C:/Users/${Username}/ isn't solving it.

copyrat90 avatar May 08 '21 09:05 copyrat90

Or put .clang-format in your home directory?

Ah, that works. Thanks for the suggestion. :)

I'm having the same issue, but in my case, placing .clang-format on C:/Users/${Username}/ isn't solving it.

That trick only works if all the projects you are working on are in a subdirectory of your home folder. If, for example, you have a project stored on another drive then it won't be found. Another windows caveat is it likes to hide part of the filename so you need to be sure there is nothing hidden and it's named exactly .clang-format.

njames93 avatar May 08 '21 10:05 njames93