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

Clang-formatter don't allow work another code formatter #303

Closed
astand opened this issue Oct 20, 2016 · 13 comments
Closed

Clang-formatter don't allow work another code formatter #303

astand opened this issue Oct 20, 2016 · 13 comments

Comments

@astand
Copy link

astand commented Oct 20, 2016

After installing extension my previous formatter has stopped working. I really don't know how force to work extension and other formatter together? Is there some method? ("C_Cpp.clang_format_fallbackStyle": "none" - not works)

@delmyers
Copy link
Contributor

My guess is that vscode picks an extension to go with somehow. @sean-mcmanus, do you know a way to get this to work?

@greazer
Copy link
Member

greazer commented Oct 21, 2016

@astand, currently our extension does not provide a way to turn off the code-formatting feature that's built into it. This is something that we will definitely consider for our next release as VSCode overall does not provide an ability to force the order of extensions being used. Therefore if there are two extensions loaded that have similar functionality, only one of them will win.

That being said, is there something in particular about the other formatter your using that you like or something in particular about our formatter that you find lacking?

@astand
Copy link
Author

astand commented Oct 21, 2016

@greazer, I am using astyle extension, I used it before vscode and it is very familiar to me.
I guess that there is no a big conceptual difference between them, and I tried to use clang-formater from the extension but I really don't understand how to work with .clang-format option file. I put it in different locations on pc (LLVM/bin, project workspace, .vscode folder, unrelated folders), tried set "C_Cpp.clang_format_style": "path" - with absolute or relative path format.
It is still not works. (Astyle option file uses the same way, and it works)
Content of file is very simple:
BasedOnStyle: LLVM

@jrieken
Copy link
Member

jrieken commented Oct 21, 2016

@delmyers When two matching formatters for a language are available VS Code picks the one that came last. This isn't ideal, for October we are working on resolving this, and we also need your support here. After a long thought process and weighing options we agreed on adding settings for our formatters, like typescript.format.enable: true|false such that another registered formatter can be picked. See microsoft/vscode#11609 all the details.

Our ask for you guys would be to add a setting ala cpp.format.enable such that users can decide if they want to use the formatter the language service provides or their formatter-extension.

@greazer
Copy link
Member

greazer commented Oct 24, 2016

@jrieken Thanks, we'll be adding this switch to our extension. Most likely our next release.
@astand The way clang format works is by looking for a .clang-format or _clang-format file in the same folder or one of the parent folders of the source that's being formatted. Also note that C_Cpp.clang_format_style is not used to set the path to the .clang-format file.

@greazer
Copy link
Member

greazer commented Oct 24, 2016

@astand Oh, it's also important to not set C_Cpp.clang_format_style at all, or set it to "file" in order to make our formatter look for the .clang-format file. This may be the source of the problems you're having since it sounds like you're trying to set the path the .clang-format file using that option. That won't work.

@astand
Copy link
Author

astand commented Oct 25, 2016

@greazer Thanks, i've got it. I deleted wrong settings (all related to c_cpp.clang_*) and added ".clang-format" file to source code dir. It has only one string - {BasedOnStyle: Visual Studio}. Predefined style - "Visual Studio" but formatter applies another style (I guess that it is LLVM) . When I delete ".clang-format" file, formatter uses Visual Studio style.

@jrieken
Copy link
Member

jrieken commented Nov 23, 2016

@delmyers Any update on this? Can we help with the change?

@sean-mcmanus
Copy link
Collaborator

Yeah, an update with the formatter enable/disable option is planned to be released soon in 0.9.3.

@Gruntfuggly
Copy link

It doesn't look like this made it into 0.9.3? Any idea when it will? It's a bit of a dealbreaker for me - I'd love to use this extension, but my legacy codebase is not consistently formatted, and I don't want to make wholesale formatting changes unnecessarily. It seems a bit crazy not to allow formatting to be disabled in some way or other...

@astand
Copy link
Author

astand commented Jan 25, 2017

Yes, it has not any changes in this problem. VS code makes things simpler ( I may enable/disable my formatter and it is again in work state), but it is no much less annoying.

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jan 25, 2017

We're releasing an update with the fix today, unless something unexpected happens.

@xaverh
Copy link

xaverh commented Feb 6, 2017

Thanks, It's working!

@bobbrow bobbrow closed this as completed Mar 9, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2020
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

8 participants