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

Ivan Donchevskii via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 12 00:15:31 PDT 2018


Hi!


I've decided not to wait but to try something myself :)

Check this out - https://reviews.llvm.org/D53072

This fixes some problems for me and I only need to add some string to the new empty line not to have indentation removed.


Kind regards,

Ivan

________________________________
From: Sam McCall <sammccall at google.com>
Sent: Friday, October 12, 2018 9:04:24 AM
To: Ivan Donchevskii
Cc: clang developer list
Subject: Re: [cfe-dev] [clang-format] Trying to use libFormat for code indentation

Hi Ivan,
We're also interested in as-you-type formatting like indentation for clangd.
(http://lists.llvm.org/pipermail/clangd-dev/2018-September/000102.html)
But I don't think anyone's deeply explored what would be needed from libFormat to allow this.
Cheers, Sam

On Fri, Oct 5, 2018 at 1:31 PM Ivan Donchevskii via cfe-dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> wrote:

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<mailto: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/20181012/cc49d2b2/attachment.html>


More information about the cfe-dev mailing list