forked from cappuccino/cappuccino
/
objj.vim
197 lines (168 loc) · 6.82 KB
/
objj.vim
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
" Vim syntax file
" Language: Objective-J
" Maintainer: Shawn MacIntyre <sdm@openradical.com>
" Updaters:
" URL:
" Changes: (sm) merged javascript syntax Claudio Fleiner and Scott Shattuck and objc syntax by Kazunobu Kuriyama and Anthony Hodsdon
" Last Change: 2008 Sep 8
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
" tuning parameters:
" unlet objj_fold
if !exists("main_syntax")
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let main_syntax = 'objj'
endif
" Drop fold if it set but vim doesn't support it.
if version < 600 && exists("objj_fold")
unlet objj_fold
endif
syn case ignore
" objj keywords, types, type qualifiers etc.
syn keyword objjStatement self super _cmd
syn keyword objjType id Class SEL IMP BOOL
"syn keyword objjTypeModifier bycopy in out inout oneway
syn keyword objjConstant nil Nil
" Match the objj #import directive (like C's #include)
syn region objjImported display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match objjImported display contained "<[_0-9a-zA-Z.\/]*>"
syn match objjImport display "^\s*\(%:\|#\)\s*import\>\s*["<]" contains=objjImported
" Match the important objj directives
syn match objjScopeDecl "@public\|@private\|@protected"
syn match objjDirective "@interface\|@implementation"
syn match objjDirective "@class\|@end\|@defs"
syn match objjDirective "@encode\|@protocol\|@selector"
syn match objjDirective "@try\|@catch\|@finally\|@throw\|@synchronized"
" Match the ObjC method types
"
" NOTE: here I match only the indicators, this looks
" much nicer and reduces cluttering color highlightings.
" However, if you prefer full method declaration matching
" append .* at the end of the next two patterns!
"
syn match objjInstMethod "^\s*-\s*"
syn match objjFactMethod "^\s*+\s*"
" To distinguish from a header inclusion from a protocol list.
"syn match objjProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objjType,cType,Type
" To distinguish labels from the keyword for a method's parameter.
syn region objjKeyForMethodParam display
\ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*("
\ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*"
\ contains=objjType,Type
" Objective-C Constant Strings
syn match objjSpecial display "%@" contained
syn region objjString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial
" Objective-C Message Expressions
syn region objjMessage display start="\[" end="\]" contains=objjMessage,objjStatement,objjType,objjTypeModifier,objjString,objjConstant,objjDirective
syn cluster cParenGroup add=objjMessage
syn cluster cPreProcGroup add=objjMessage
syn keyword objjCommentTodo TODO FIXME XXX TBD contained
syn match objjLineComment "\/\/.*" contains=objjCommentTodo
syn match objjCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
syn region objjComment start="/\*" end="\*/" contains=objjCommentTodo
syn match objjSpecial "\\\d\d\d\|\\."
syn region objjStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=objjSpecial,@htmlPreproc
syn region objjStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=objjSpecial,@htmlPreproc
syn match objjSpecialCharacter "'\\.'"
syn match objjNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
syn region objjRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
syn keyword objjConditional if else switch
syn keyword objjRepeat while for do in
syn keyword objjBranch break continue
syn keyword objjOperator new delete instanceof typeof
syn keyword objjType Array Boolean Date Function Number Object String RegExp
syn keyword objjStatement return with
syn keyword objjBoolean true false
syn keyword objjNull null undefined
syn keyword objjIdentifier arguments this var
syn keyword objjLabel case default
syn keyword objjException try catch finally throw
syn keyword objjMessage alert confirm prompt status
syn keyword objjGlobal self window top parent
syn keyword objjMember document event location
syn keyword objjDeprecated escape unescape
syn keyword objjReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile
if exists("objj_fold")
syn match objjFunction "\<function\>"
syn region objjFunctionFold start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend
syn sync match objjSync grouphere objjFunctionFold "\<function\>"
syn sync match objjSync grouphere NONE "^}"
setlocal foldmethod=syntax
setlocal foldtext=getline(v:foldstart)
else
syn keyword objjFunction function
syn match objjBraces "[{}\[\]]"
syn match objjParens "[()]"
endif
syn sync fromstart
syn sync maxlines=100
if main_syntax == "objj"
syn sync ccomment objjComment
endif
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_objj_syn_inits")
if version < 508
let did_objj_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink objjComment Comment
HiLink objjLineComment Comment
HiLink objjCommentTodo Todo
HiLink objjSpecial Special
HiLink objjStringS String
HiLink objjStringD String
HiLink objjCharacter Character
HiLink objjSpecialCharacter objjSpecial
HiLink objjNumber objjValue
HiLink objjConditional Conditional
HiLink objjRepeat Repeat
HiLink objjBranch Conditional
HiLink objjOperator Operator
HiLink objjType Type
HiLink objjStatement Statement
HiLink objjFunction Function
HiLink objjBraces Function
HiLink objjError Error
HiLink javaScrParenError objjError
HiLink objjNull Keyword
HiLink objjBoolean Boolean
HiLink objjRegexpString String
HiLink objjIdentifier Identifier
HiLink objjLabel Label
HiLink objjException Exception
HiLink objjMessage Keyword
HiLink objjGlobal Keyword
HiLink objjMember Keyword
HiLink objjDeprecated Exception
HiLink objjReserved Keyword
HiLink objjDebug Debug
HiLink objjConstant Label
HiLink objjImport Include
HiLink objjImported String
HiLink objjTypeModifier objjType
HiLink objjType Type
HiLink objjScopeDecl Statement
HiLink objjInstMethod Function
HiLink objjFactMethod Function
HiLink objjStatement Statement
HiLink objjDirective Statement
HiLink objjKeyForMethodParam None
HiLink objjString String
HiLink objjSpecial Special
HiLink objjProtocol None
HiLink objjConstant Constant
delcommand HiLink
endif
let b:current_syntax = "objj"
if main_syntax == 'objj'
unlet main_syntax
endif
" vim: ts=8