[cfe-dev] [clang-format] Trying to use libFormat for code indentation

Ivan Donchevskii via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 5 04:31:33 PDT 2018


libFormat and clang-format are great for formatting but I want to use libFormat a bit differently - to provide the indentation for the next line (inside IDE, when you press CR in code editor).

Probably I miss some handy flag which helps with that but so far I've found only workarounds to do what I need:

 - add some stupid expression to the new line (something like "a;") to force libFormat indent it

 - play with clang-format flags to prevent it from shrinking the new line into the previous one

 - set ColumnLimit to the length of the previous line also to prevent shrinking

All of them work completely unreliably. Also it's often some incomplete code in the middle of typing so it might have unfinished expressions.

So I want to ask if somebody has/had similar use cases and knows how to deal with them before adding some special flag to clang-format and trying to solve my issues there.

Kind regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181005/5309975e/attachment.html>

More information about the cfe-dev mailing list