CppStyle
CppStyle copied to clipboard
Allow clang-format path configuration in project settings
For managing toolchains for older versions of our product, it would be great to be able to store the clang-format executable path in the project settings and not in the workspace settings.
This would also ease up using a version controlled Eclipse project with non-standard clang-format command: everything else comes from the project itself but now we need to manually set up clang-format path for the workspace.
I implemented this on my fork for java formatting: https://github.com/AhmetBilgin/ClangFormat4J/commit/a5a6f09e084016a90a8a5f4b2b970038bdfa6c38
Hello @AhmetBilgin, could you submit a PR to this project implementing this feature ? Would love to have it ! Thanks a lot.
Hi @julian-poidevin, I had to use another account to fork this project again. Can you test this? Seems to work for me. https://github.com/Nosezeichen/CppStyle/tree/master/update/target/site When it's ok I'll make a Pull-Request.
Hi @AhmetBilgin, thanks for taking the time to do this. I've installed your modified version of the CppStyle extension and re-configured the path. Unfortunately I don't see the project file being modified with the settings.
I'm using STM32CubeIDE, is your patch compatible with this modified version of Eclipse ? The project file has a .cproject
extension
Also, I see your patch allows to set clang-format path with an environment variable env_var
.
Would it work using Eclipse linked ressource as : ${PROJECT_LOC}
.
I'd like to directly put the clang-format
binary into a project folder so developers don't have to install LLVM and I'd like to set the clang-format
path in the project settings as : ${PROJECT_LOC}
/Utilities/clang-format.exe
Thanks a lot for your help on this !
Hi @julian-poidevin, I don't know why I said that I implemented the 'project specific settings' part... You are right, with my changes you are able to to use ${env_var:SOMETHING} in all 3 fields (clang-format, .clang-format style and cpplint). You can even use multiple semicolon ';' seperated paths. The first valid one will be used. But these settings are only available at workspace level right now.
- (A) I can have a look if I can implement this as project settings as well.
The environment variable resolving does currently only work for ${env_var:SOMETHING} and is resolved with System::getEnv and System::getproperty.
- (B) I can have a look at resolving against the eclipse predefined path variables. This will get a little bit trickier, because I cache the first valid path until the path changes in the settings or eclipse is restarted. This won't work if you want different settings for different projects in the same workspace.
Which solution (A, B) would help with your requirements?
Wow, that's very nice from you suggesting your help ! 🙏🏻
Actually, solution (B) could help a lot. I would just have to store clang-format
binary at the same place for all project.
Thanks a lot !