[Qt-creator] Qt Creator beautifier plugin vs. built-in code style

Andy asmaloney at gmail.com
Tue Aug 22 14:36:49 CEST 2017


My 2 cents:

I watched the video (good stuff - thanks!) grabbed clang-format, found this
awesome site to create the configuration:

  https://zed0.co.uk/clang-format-configurator/

and played with it in Qt Creator.

Overall I think it's great. I've done some work with Go and I love that
go-fmt is run every time I save a file (in Atom). It would be amazing to
have that capability with clang-format and Qt Creator.

The one thing I couldn't get it to do is indent code after accessor
keywords. Using "AccessModifierOffset" I can do this:

{
public:
   void foo();
}

or this:

{
   public:
   void foo();
}

But not the one I want, which is this:

{
   public:
      void foo();
}

If anyone has clues on how to accomplish this I'll be a happy humanoid.


---
Andy Maloney  //  https://asmaloney.com
twitter ~ @asmaloney <https://twitter.com/asmaloney>


On Tue, Aug 22, 2017 at 3:29 AM, Nikolai Kosjar <nikolai.kosjar at qt.io>
wrote:

> On 08/21/2017 08:18 PM, Timur Kristóf wrote:
>
>> Hi,
>>
>> I noticed that the built-in code style options somewhat clash with the
>> beautifier plugin. (I notice that the code style settings don't affect
>> the beautifier plugin at all, and the beautifier settings are rather
>> rudimentary at the moment.)
>>
>> What are the long-term plans in this regard?
>>
>> Do you guys intend to improve the built-in code styling, or do you want
>> to eventually replace it with either the beautifier or something based
>> on clang-format?
>>
> Evaluation is on-going :)
>
> I'm playing around with clang-format for the Qt Creator code base to see
> whether it can replace our built-in code style use cases and how well it
> can handle our code style/formatting.
>
> Some general observations:
>
> 1. Qt Creator has a built-in *indenter*, handling/controlling whitespace
> before the first token of a line.
>
> 2. clang-format does this and more:
>  * it handles/controls whitespace everywhere, also taking a maximum column
> count into account
>  * it can e.g. also sort your includes and add comments at the closing
> curly brace of namespaces: "} // namespace X".
>
> 3. The beautifier-plugin for clang-format allows to format the entire file
> or text selections of it. Changed lines are properly indicated by red
> vertical stripes in the left editor margin, which is cool. The plugin does
> not yet make use of the -cursor argument, which allows to format the AST at
> cursor position and probably would be useful/needed to replace current
> on-enter-indendation.
>
> Nikolai
>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20170822/e6cd579f/attachment-0001.html>


More information about the Qt-creator mailing list