Sublime Forum

How to force LSP to use Allman style for c/c++?

#1

Is it possible to change the settings to use Allman style for c/c++? I followed the guidelines from https://lsp.sublimetext.io/guides/cplusplus/, but I could not find any related settings regarding this.

For example, the following style

void func()
{

}
0 Likes

#2

LSP, as a general framework, doesn’t do any exact job, it just obeys server responses. You would have to check the document of your used language server (e.g., maybe clangd, which actually uses clang-format for formatting).

After googling clangd Allman, you can quickly find this https://gist.github.com/maddouri/f9239a941ea753bafeb658e330ae92ab#file-clang-format-L20. So it’s likely can be done by creating a .clang-format file with that line included in your project root. Or maybe you want to use the whole file with some minor modifications since it claims it’s for Allman-style formatting. .clang-format generator: https://zed0.co.uk/clang-format-configurator/

0 Likes

#3

Using this emacs lisp setting one ends up with BSD/Allman style braces but introduces tabs with 8 spaces.

0 Likes

#4

Thanks. Creating a .clang-format file is the right way to go.

0 Likes

#5

Thanks and regards..

0 Likes