Run External tool on filesave

I configured an "external tool" to run clan-format and format the code with the company's default configuration file.

Is there any way to automatically run it when the file is saved?

thanks.



Attachment(s):
Screen Shot 2015-10-16 at 15.29.08.png
1
7 comments

Hi Ignazio.

It's not implemented yet. There is a hacky-way to run external tools on save (please see http://marcesher.com/2014/03/30/intellij-idea-run-goimports-on-file-save/). Does that help?
Also I've created the issue in our tracker: https://youtrack.jetbrains.com/issue/CPP-4805. Feel free to comment or upvote.

0

Ignazio,

What's the purpose of using clang-format, when AppCode has built-in code style formatter that works on the fly, while you are typing the code. Just set it once and then use it everywhere. You can also out it to VCS together with the prj or simply share as a stand-alone settings (file) with the team.

Moreover there is no special action for "saving" files in AppCode, since files are saved automatically.

0

Not sure about Ignazio, but on our team we use SpaceCommander (https://github.com/square/spacecommander), which uses the .clang-format file to enforce formatting. Not everyone on the team uses AppCode, so an AppCode-only solution won't fly.

Somewhat related, it'd be great if there was a way to have AppCode use .clang-format for formatting options. (Edit: nevermind, just read the issue you created)

0

Hi Anastasia,
I understand that Appcode has a very good and powerfull way to format code, but in my team a lot of people are using xcode and the clang-format is the company standard. I'm not sure if I can replicate exactly the same behaviour using appcode rulese, in any case this require a lot of work. For sure more that setup an external tool + shortcut.

I'm 80% happy with my current setup :)

0

Hi Ignazio,

I'm very new to AppCode and would also like to use ClangFormat as well. I have it on my XCode setup but currently XCode has been a little too buggy and now I'm looking at AppCode as an alternative. It would be great if you could help me set it up once you've got it up and running. Thanks!

0

You should be able to replicate the same configuration in AppCode settings with ease.

And yu can also run the external tool currently, however running it on Save is not possible now (still, link to the "trick" below can do the job most likely), and I'm not sure we can introduce this quickly due to auto-save working across the whole platform, which AppCode is based on. You can follow the ticket linked above for further progress.

0

As you can read from this topic, there are a couple of ways to configure Appcode to format the code as uncrustify...the first solution is to replicate the uncrustify configuration with the one that is provided by Appcode...althoug this is technically possible it can require a bit of work execially if you have about 100 rules on your .clangFormat.

The second way is to configure an external tool (you can see the configuration on my original post). You can also configure a shortcut to run this external tool, but unfortunately is not possible to run it automatically when you save the file (as the BBUncrustify xcode plugin). This artile (http://marcesher.com/2014/03/30/intellij-idea-run-goimports-on-file-save/) proposes a cool trick, use the same shortcut to save the file and to run the tool, it should work.

0

Please sign in to leave a comment.