199
|
1 " Vim syntax file for the D programming language (version 0.116).
|
7
|
2 "
|
17
|
3 " Language: D
|
|
4 " Maintainer: Jason Mills<jmills@cs.mun.ca>
|
199
|
5 " Last Change: 2005 Mar 09
|
|
6 " Version: 0.12
|
7
|
7 "
|
|
8 " Options:
|
|
9 " d_comment_strings - set to highlight strings and numbers in comments
|
|
10 "
|
|
11 " d_hl_operator_overload - set to highlight D's specially named functions
|
|
12 " that when overloaded implement unary and binary operators (e.g. cmp).
|
|
13 "
|
|
14 " Todo:
|
|
15 " - Allow user to set sync minlines
|
|
16 "
|
|
17 " - Several keywords (namely, in and out) are both storage class and
|
|
18 " statements, depending on their context. Must use some matching to figure
|
|
19 " out which and highlight appropriately. For now I have made such keywords
|
|
20 " statements.
|
|
21 "
|
|
22 " - Mark contents of the asm statement body as special
|
|
23 "
|
|
24
|
|
25 " Quit when a syntax file was already loaded
|
|
26 if exists("b:current_syntax")
|
|
27 finish
|
|
28 endif
|
|
29
|
|
30 " Keyword definitions
|
|
31 "
|
17
|
32 syn keyword dExternal import package module extern
|
|
33 syn keyword dConditional if else switch
|
|
34 syn keyword dBranch goto break continue
|
|
35 syn keyword dRepeat while for do foreach
|
|
36 syn keyword dBoolean true false
|
|
37 syn keyword dConstant null
|
199
|
38 syn keyword dConstant __FILE__ __LINE__ __DATE__ __TIME__ __TIMESTAMP__
|
17
|
39 syn keyword dTypedef alias typedef
|
|
40 syn keyword dStructure template interface class enum struct union
|
|
41 syn keyword dOperator new delete typeof typeid cast align is
|
|
42 syn keyword dOperator this super
|
7
|
43 if exists("d_hl_operator_overload")
|
17
|
44 syn keyword dOpOverload opNeg opCom opPostInc opPostDec opAdd opSub opSub_r
|
|
45 syn keyword dOpOverload opMul opDiv opDiv_r opMod opMod_r opAnd opOr opXor
|
|
46 syn keyword dOpOverload opShl opShl_r opShr opShr_r opUShr opUShr_r opCat
|
|
47 syn keyword dOpOverload opCat_r opEquals opEquals opCmp opCmp opCmp opCmp
|
|
48 syn keyword dOpOverload opAddAssign opSubAssign opMulAssign opDivAssign
|
|
49 syn keyword dOpOverload opModAssign opAndAssign opOrAssign opXorAssign
|
|
50 syn keyword dOpOverload opShlAssign opShrAssign opUShrAssign opCatAssign
|
199
|
51 syn keyword dOpOverload opIndex opIndexAssign opCall opSlice opPos
|
17
|
52 syn keyword dOpOverload opAdd_r opMul_r opAnd_r opOr_r opXor_r
|
7
|
53 endif
|
17
|
54 syn keyword dType ushort int uint long ulong float
|
|
55 syn keyword dType void byte ubyte double bit char wchar ucent cent
|
|
56 syn keyword dType short bool dchar
|
|
57 syn keyword dType real ireal ifloat idouble creal cfloat cdouble
|
|
58 syn keyword dDebug deprecated unittest
|
|
59 syn keyword dExceptions throw try catch finally
|
|
60 syn keyword dScopeDecl public protected private export
|
|
61 syn keyword dStatement version debug return with invariant body
|
|
62 syn keyword dStatement in out inout asm mixin
|
|
63 syn keyword dStatement function delegate
|
|
64 syn keyword dStorageClass auto static override final const abstract volatile
|
|
65 syn keyword dStorageClass synchronized
|
|
66 syn keyword dPragma pragma
|
7
|
67
|
|
68
|
|
69 " Assert is a statement and a module name.
|
|
70 syn match dAssert "^assert\>"
|
|
71 syn match dAssert "[^.]\s*\<assert\>"ms=s+1
|
|
72
|
|
73 " Marks contents of the asm statment body as special
|
|
74 "
|
|
75 " TODO
|
|
76 "syn match dAsmStatement "\<asm\>"
|
|
77 "syn region dAsmBody start="asm[\n]*\s*{"hs=e+1 end="}"he=e-1 contains=dAsmStatement
|
|
78 "
|
|
79 "hi def link dAsmBody dUnicode
|
|
80 "hi def link dAsmStatement dStatement
|
|
81
|
|
82 " Labels
|
|
83 "
|
|
84 " We contain dScopeDecl so public: private: etc. are not highlighted like labels
|
17
|
85 syn match dUserLabel "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=dLabel,dScopeDecl
|
|
86 syn keyword dLabel case default
|
7
|
87
|
|
88 " Comments
|
|
89 "
|
17
|
90 syn keyword dTodo contained TODO FIXME TEMP XXX
|
|
91 syn match dCommentStar contained "^\s*\*[^/]"me=e-1
|
|
92 syn match dCommentStar contained "^\s*\*$"
|
|
93 syn match dCommentPlus contained "^\s*+[^/]"me=e-1
|
|
94 syn match dCommentPlus contained "^\s*+$"
|
7
|
95 if exists("d_comment_strings")
|
17
|
96 syn region dBlockCommentString contained start=+"+ end=+"+ end=+\*/+me=s-1,he=s-1 contains=dCommentStar,dUnicode,dEscSequence,@Spell
|
|
97 syn region dNestedCommentString contained start=+"+ end=+"+ end="+"me=s-1,he=s-1 contains=dCommentPlus,dUnicode,dEscSequence,@Spell
|
|
98 syn region dLineCommentString contained start=+"+ end=+$\|"+ contains=dUnicode,dEscSequence,@Spell
|
|
99 syn region dBlockComment start="/\*" end="\*/" contains=dBlockCommentString,dTodo,@Spell
|
|
100 syn region dNestedComment start="/+" end="+/" contains=dNestedComment,dNestedCommentString,dTodo,@Spell
|
|
101 syn match dLineComment "//.*" contains=dLineCommentString,dTodo,@Spell
|
7
|
102 else
|
17
|
103 syn region dBlockComment start="/\*" end="\*/" contains=dBlockCommentString,dTodo,@Spell
|
|
104 syn region dNestedComment start="/+" end="+/" contains=dNestedComment,dNestedCommentString,dTodo,@Spell
|
|
105 syn match dLineComment "//.*" contains=dLineCommentString,dTodo,@Spell
|
7
|
106 endif
|
|
107
|
17
|
108 hi link dLineCommentString dBlockCommentString
|
|
109 hi link dBlockCommentString dString
|
|
110 hi link dNestedCommentString dString
|
|
111 hi link dCommentStar dBlockComment
|
|
112 hi link dCommentPlus dNestedComment
|
7
|
113
|
|
114 syn sync minlines=25
|
|
115
|
|
116 " Characters
|
|
117 "
|
|
118 syn match dSpecialCharError contained "[^']"
|
|
119
|
199
|
120 " Escape sequences (oct,specal char,hex,wchar, character entities \&xxx;)
|
|
121 " These are not contained because they are considered string litterals
|
17
|
122 syn match dEscSequence "\\\(\o\{1,3}\|[\"\\'\\?ntbrfva]\|u\x\{4}\|U\x\{8}\|x\x\x\)"
|
199
|
123 syn match dEscSequence "\\&[^;& \t]\+;"
|
17
|
124 syn match dCharacter "'[^']*'" contains=dEscSequence,dSpecialCharError
|
|
125 syn match dCharacter "'\\''" contains=dEscSequence
|
|
126 syn match dCharacter "'[^\\]'"
|
7
|
127
|
|
128 " Unicode characters
|
|
129 "
|
17
|
130 syn match dUnicode "\\u\d\{4\}"
|
7
|
131
|
199
|
132
|
|
133
|
7
|
134 " String.
|
|
135 "
|
17
|
136 syn region dString start=+"+ end=+"+ contains=dEscSequence,@Spell
|
|
137 syn region dRawString start=+`+ skip=+\\`+ end=+`+ contains=@Spell
|
|
138 syn region dRawString start=+r"+ skip=+\\"+ end=+"+ contains=@Spell
|
|
139 syn region dHexString start=+x"+ skip=+\\"+ end=+"+
|
7
|
140
|
|
141 " Numbers
|
|
142 "
|
|
143 syn case ignore
|
17
|
144 syn match dInt display "\<\d[0-9_]*\(u\=l\=\|l\=u\=\)\>"
|
7
|
145 " Hex number
|
17
|
146 syn match dHex display "\<0x[0-9a-f_]\+\(u\=l\=\|l\=u\=\)\>"
|
|
147 syn match dHex display "\<\x[0-9a-f_]*h\(u\=l\=\|l\=u\=\)\>"
|
7
|
148 " Flag the first zero of an octal number as something special
|
17
|
149 syn match dOctal display "\<0[0-7_]\+\(u\=l\=\|l\=u\=\)\>" contains=cOctalZero
|
|
150 syn match dOctalZero display contained "\<0"
|
7
|
151
|
|
152 "floating point without the dot
|
17
|
153 syn match dFloat display "\<\d[0-9_]*\(fi\=\|l\=i\)\>"
|
7
|
154 "floating point number, with dot, optional exponent
|
17
|
155 syn match dFloat display "\<\d[0-9_]*\.[0-9_]*\(e[-+]\=[0-9_]\+\)\=[fl]\=i\="
|
7
|
156 "floating point number, starting with a dot, optional exponent
|
17
|
157 syn match dFloat display "\(\.[0-9_]\+\)\(e[-+]\=[0-9_]\+\)\=[fl]\=i\=\>"
|
7
|
158 "floating point number, without dot, with exponent
|
17
|
159 "syn match dFloat display "\<\d\+e[-+]\=\d\+[fl]\=\>"
|
|
160 syn match dFloat display "\<\d[0-9_]*e[-+]\=[0-9_]\+[fl]\=\>"
|
7
|
161
|
|
162 "floating point without the dot
|
17
|
163 syn match dHexFloat display "\<0x\x\+\(fi\=\|l\=i\)\>"
|
7
|
164 "floating point number, with dot, optional exponent
|
17
|
165 syn match dHexFloat display "\<0x\x\+\.\x*\(p[-+]\=\x\+\)\=[fl]\=i\="
|
7
|
166 "floating point number, without dot, with exponent
|
17
|
167 syn match dHexFloat display "\<0x\x\+p[-+]\=\x\+[fl]\=\>"
|
7
|
168
|
|
169 " binary numbers
|
17
|
170 syn match dBinary display "\<0b[01_]\+\>"
|
7
|
171 " flag an octal number with wrong digits
|
17
|
172 syn match dOctalError display "0\o*[89]\d*"
|
7
|
173 syn case match
|
|
174
|
|
175 " Pragma (preprocessor) support
|
|
176 " TODO: Highlight following Integer and optional Filespec.
|
|
177 syn region dPragma start="#\s*\(line\>\)" skip="\\$" end="$"
|
|
178
|
|
179
|
|
180 " The default highlighting.
|
|
181 "
|
|
182 hi def link dBinary Number
|
|
183 hi def link dInt Number
|
|
184 hi def link dHex Number
|
|
185 hi def link dOctal Number
|
|
186 hi def link dFloat Float
|
|
187 hi def link dHexFloat Float
|
|
188 hi def link dDebug Debug
|
|
189 hi def link dBranch Conditional
|
|
190 hi def link dConditional Conditional
|
|
191 hi def link dLabel Label
|
|
192 hi def link dUserLabel Label
|
|
193 hi def link dRepeat Repeat
|
|
194 hi def link dExceptions Exception
|
|
195 hi def link dAssert Statement
|
|
196 hi def link dStatement Statement
|
|
197 hi def link dScopeDecl dStorageClass
|
|
198 hi def link dStorageClass StorageClass
|
|
199 hi def link dBoolean Boolean
|
|
200 hi def link dUnicode Special
|
|
201 hi def link dRawString String
|
|
202 hi def link dString String
|
|
203 hi def link dHexString String
|
|
204 hi def link dCharacter Character
|
|
205 hi def link dEscSequence SpecialChar
|
|
206 hi def link dSpecialCharError Error
|
|
207 hi def link dOctalError Error
|
|
208 hi def link dOperator Operator
|
|
209 hi def link dOpOverload Operator
|
|
210 hi def link dConstant Constant
|
|
211 hi def link dTypedef Typedef
|
|
212 hi def link dStructure Structure
|
|
213 hi def link dTodo Todo
|
|
214 hi def link dType Type
|
|
215 hi def link dLineComment Comment
|
|
216 hi def link dBlockComment Comment
|
|
217 hi def link dNestedComment Comment
|
|
218 hi def link dExternal Include
|
|
219 hi def link dPragma PreProc
|
|
220
|
|
221 let b:current_syntax = "d"
|
|
222
|
|
223 " vim: ts=8
|