Skip to content

Commit

Permalink
Merge pull request #303 from Countly/format
Browse files Browse the repository at this point in the history
clang-format integration to format code
  • Loading branch information
turtledreams authored May 16, 2024
2 parents 4e5a4ab + 98d0a1d commit 7601991
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Basic indentation settings
IndentWidth: 2
TabWidth: 2
ContinuationIndentWidth: 4
UseTab: Never
IndentPPDirectives: BeforeHash

# Code formatting rules
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
ColumnLimit: 300

# Blank lines
MaxEmptyLinesToKeep: 1

# Alignment
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignOperands: true
AlignTrailingComments: true

# Import statements
SortIncludes: true
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ let package = Package(
"LICENSE",
"README.md",
"countly_dsym_uploader.sh",
"format.sh",
"CHANGELOG.md",
"SECURITY.md",
"CountlyTests/"
Expand Down
17 changes: 17 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

CDP=$(osascript -e '
tell application "Xcode"
activate
--wait for Xcode to remove edited flag from filename
delay 0.3
set last_word_in_main_window to (word -1 of (get name of window 1))
set current_document to document 1 whose name ends with last_word_in_main_window
set current_document_path to path of current_document
--CDP is assigned last set value: current_document_path
end tell ')

sleep 0.6 ### during save Xcode stops listening for file changes
/usr/local/bin/clang-format -style=file -i ${CDP}

# EOF

0 comments on commit 7601991

Please sign in to comment.