eclipse-cdt/cdt-lsp

Not respecting and format in the eclipse configurations.

Opened this issue · 4 comments

Which ever format I try to select from the preferences in eclipse
C/C++ -> Code Style -> Formatter

I see that the editor is always going back to some default formatter like K&R.

It would be helpful if you can provide someway to make that work. Maybe I am missing something. Also let me know if there are some changes required in the implementation or point me to the particular file you are using for the formatting and I can see if in our integration we can change it in a way to utalize the code style from eclipse

The formatting in the new LSP based editor relies on a .clang-format file in the source file folder or its parents (e.g. a .clang-format file in the project root will be used for all source files in the project)

Here is a little documentation how its works.

The format info comes from the clangd language server. The formatting defined in the .clang-format will also be applied via the Ctrl+Shift+F shortcut or via the context menu in the editor:
image

@ghentschke thanks for the quick response can you please also let me know why the color formatting is not working in the eclipse as well?

Which editor are u using? In the old editor you can run the formatter via context menu:
image
Or you can tell Eclipse to format your file on file save:
image