Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify a path for .clang-format via VS Code settings.json #10445

Closed
rongxin-liu opened this issue Jan 31, 2023 · 5 comments
Closed

Specify a path for .clang-format via VS Code settings.json #10445

rongxin-liu opened this issue Jan 31, 2023 · 5 comments

Comments

@rongxin-liu
Copy link

Feature Request

Currently, per this documentation, VS Code would look for a .clang-format file in user's workspace and apply those settings. If .clang-format file is not found, it uses its default formatting style shipped with the C/C++ extension.

Would it be possible for users to specify the .clang-format file at a location other than the workspace, perhaps in settings.json, allowing more flexibility?

@rongxin-liu
Copy link
Author

The context is we want to ship our customized .clang-format file in a Docker image. Users launching a dev container using our image (with the accompanied .devcontainer.json) can automatically use our formatting styles without extra configuration.

@michelleangela michelleangela added duplicate Feature: Code Analysis Related to integration with clang-tidy, cppcheck, cl.exe /analyze, etc. Feature Request labels Jan 31, 2023
@michelleangela
Copy link
Contributor

@rongxin-liu
Thank you for submitting this request. It is a duplicate of #10006. The current workaround is to add the clang-tidy arg --config-file=<path> to the setting C_Cpp.codeAnalysis.clangTidy.args.

@rongxin-liu
Copy link
Author

@michelleangela Thanks! But I'm looking into specifying a file path for .clang-format file, not clang-tidy config file. Is there a workaround for that?

@rongxin-liu
Copy link
Author

@michelleangela Ah, just found out that this setting does exactly what we need:

"C_Cpp.clang_format_style": "file:/home/ubuntu/.clang-format"

@michelleangela
Copy link
Contributor

@rongxin-liu
My apologies, I misread and thought of clang-tidy. Yes, the setting C_Cpp.clang_format_style can be set with a path to .clang-format file.

@michelleangela michelleangela added Feature: Code Formatting question and removed Feature: Code Analysis Related to integration with clang-tidy, cppcheck, cl.exe /analyze, etc. duplicate Feature Request labels Feb 1, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants