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

Jonas Toth via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 5 06:16:51 PDT 2018


Hi Ivan,


take a look at this one:
https://clang.llvm.org/doxygen/classclang_1_1Lexer.html#a9102a4b3ccbed3505f6d002502193793

The Lexer provides a function that gives the indendation for a line,
given that you seem to know the line of interest you can probably query
the Lexer there.


Best Jonas


Am 05.10.2018 um 13:31 schrieb Ivan Donchevskii via cfe-dev:
>
> Hi,
>
>
> 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,
>
> Ivan
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

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


More information about the cfe-dev mailing list