SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 06/07/2018, 12:55 PM   #1
[HLF]Southclaw
Godfather
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 5,008
Reputation: 1578
Default clang-format config for Pawn

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.
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is offline   Reply With Quote
Old 09/12/2018, 11:40 PM   #2
Alteh
Big Clucker
 
Join Date: Aug 2018
Location: Narnia
Posts: 57
Reputation: 5
Default Re: clang-format config for Pawn

Was looking for something like that

I'm gonna take a look
Alteh is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
YINI Saving With "File" Format Instead Of "Config. Settings" TheRaGeLord Scripting Help 3 18/07/2015 03:11 PM
Format() function in PHP? (conerting pawn to PHP) linuxthefish Everything and Nothing 8 07/08/2011 09:04 PM
Pawn Tutorial - format() // (Made in 2008) pmkrz PortuguÍs/Portuguese 14 03/06/2010 02:31 AM


All times are GMT. The time now is 07:58 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.