clang-format config for Pawn - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Discussion (
https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: clang-format config for Pawn (
/showthread.php?tid=656055)
clang-format config for Pawn -
[HLF]Southclaw - 06.07.2018
I recently realised clang-format (the clang formatting tool for C++, Java, ObjC and a few other languages) quite happily reads
most Pawn code.
You can check out the tool here:
https://clang.llvm.org/docs/ClangFormat.html and play with configs here:
https://clangformat.com/ or here:
https://zed0.co.uk/clang-format-configurator/
So, being a lover of conventions and strict formatting, I attempted to write a clang format config for Pawn based on the conventions that the community have adopted over the years.
It looks like this:
And the configuration is:
Code:
---
BasedOnStyle: WebKit
IndentWidth: 4
---
Language: Cpp
AlignAfterOpenBracket: DontAlign
BreakBeforeBraces: Allman
BreakConstructorInitializers: BeforeColon
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
SortIncludes: true
SpaceBeforeAssignmentOperators: false
The only issue, as you can see in the gif above, foreach is broken and I can't figure out a solution for it (outside of writing my own formatter - which was doing, and may continue).
If anyone wants to contribute, go ahead! It would be nice to have a universal format that is also enforced by a tool that can eventually be implemented into the
Pawn Tools for VS Code extension so source code is formatted upon saving the file to save time while writing.
Re: clang-format config for Pawn -
Alteh - 09.12.2018
Was looking for something like that
I'm gonna take a look