forked from textmate/c.tmbundle
/
Indentation Rules.plist
57 lines (57 loc) · 2.08 KB
/
Indentation Rules.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Indentation Rules</string>
<key>scope</key>
<string>source.c, source.c++, source.objc, source.objc++</string>
<key>settings</key>
<dict>
<key>decreaseIndentPattern</key>
<string>(?x)
^ (.*\*/)? \s* \} ( [^}{"']* \{ | \s* while \s* \( .* )? [;\s]* (//.*|/\*.*\*/\s*)? $
| ^ \s* (public|private|protected): \s* $
| ^ \s* @(public|private|protected) \s* $
</string>
<key>increaseIndentPattern</key>
<string>(?x)
^ .* \{ [^}"']* $
| ^ \s* (public|private|protected): \s* $
| ^ \s* @(public|private|protected) \s* $
</string>
<key>indentNextLinePattern</key>
<string>(?x)^
(?! .* [;:{}] # do not indent when line ends with ;, :, {, or }
\s* (//|/[*] .* [*]/ \s* $) # …account for potential trailing comment
| @(public|private|protected) # do not indent after obj-c data access keywords
)
.* [^\s;:{}] \s* $ # indent next if this one isn’t
# terminated with ;, :, {, or }
</string>
<key>unIndentedLinePattern</key>
<string>^\s*((/\*|\*/|//|#|template\b.*?>(?!\(.*\))|@protocol|@optional|@interface(?!.*\{)|@implementation|@end).*)?$</string>
<key>indentExpression</key>
<string>
;
; the code should return the absolute amount of whitespace to use for the current line
; return a negative number to use default indentation rules
;
(set text (current-text))
(set lineRange ((text textStorage) rangeOfLineAtLocation:(text caret)))
(set scope ((current-document) scopeAtLocation:(lineRange first)))
(cond
((scope match:"(source.c $ | source.c++ $ | source.objc $ | source.objc++ $ | meta.function.c - meta.block.c)")
0)
((/^\s*\{\}$/ findInString:(text line))
(text lengthOfIndentAtLocation:(- (lineRange first) 1)))
((/^\s*#/ findInString:(text line))
0)
(else -1)
)
</string>
</dict>
<key>uuid</key>
<string>02EB44C6-9203-4F4C-BFCB-7E3360B12812</string>
</dict>
</plist>