1619
|
1 " Vim syntax file
|
|
2 " Language: MS Message Text files (*.mc)
|
|
3 " Maintainer: Kevin Locke <kwl7@cornell.edu>
|
|
4 " Last Change: 2008 April 09
|
|
5 " Location: http://kevinlocke.name/programs/vim/syntax/msmessages.vim
|
|
6
|
|
7 " See format description at <http://msdn2.microsoft.com/en-us/library/aa385646.aspx>
|
|
8 " This file is based on the rc.vim and c.vim
|
|
9
|
|
10 " For version 5.x: Clear all syntax items
|
|
11 " For version 6.x: Quit when a syntax file was already loaded
|
|
12 if version < 600
|
|
13 syntax clear
|
|
14 elseif exists("b:current_syntax")
|
|
15 finish
|
|
16 endif
|
|
17
|
|
18 " Common MS Messages keywords
|
|
19 syn case ignore
|
|
20 syn keyword msmessagesIdentifier MessageIdTypedef
|
|
21 syn keyword msmessagesIdentifier SeverityNames
|
|
22 syn keyword msmessagesIdentifier FacilityNames
|
|
23 syn keyword msmessagesIdentifier LanguageNames
|
|
24 syn keyword msmessagesIdentifier OutputBase
|
|
25
|
|
26 syn keyword msmessagesIdentifier MessageId
|
|
27 syn keyword msmessagesIdentifier Severity
|
|
28 syn keyword msmessagesIdentifier Facility
|
|
29 syn keyword msmessagesIdentifier OutputBase
|
|
30
|
|
31 syn match msmessagesIdentifier /\<SymbolicName\>/ nextgroup=msmessagesIdentEq skipwhite
|
|
32 syn match msmessagesIdentEq transparent /=/ nextgroup=msmessagesIdentDef skipwhite contained
|
|
33 syn match msmessagesIdentDef display /\w\+/ contained
|
|
34 " Note: The Language keyword is highlighted as part of an msmessagesLangEntry
|
|
35
|
|
36 " Set value
|
|
37 syn case match
|
|
38 syn region msmessagesSet start="(" end=")" transparent fold contains=msmessagesName keepend
|
|
39 syn match msmessagesName /\w\+/ nextgroup=msmessagesSetEquals skipwhite contained
|
|
40 syn match msmessagesSetEquals /=/ display transparent nextgroup=msmessagesNumVal skipwhite contained
|
|
41 syn match msmessagesNumVal display transparent "\<\d\|\.\d" contains=msmessagesNumber,msmessagesFloat,msmessagesOctalError,msmessagesOctal nextgroup=msmessagesValSep
|
|
42 syn match msmessagesValSep /:/ display nextgroup=msmessagesNameDef contained
|
|
43 syn match msmessagesNameDef /\w\+/ display contained
|
|
44
|
|
45
|
|
46 " Comments are converted to C source (by removing leading ;)
|
|
47 " So we highlight the comments as C
|
|
48 syn include @msmessagesC syntax/c.vim
|
|
49 unlet b:current_syntax
|
|
50 syn region msmessagesCComment matchgroup=msmessagesComment start=/;/ end=/$/ contains=@msmessagesC keepend
|
|
51
|
|
52 " String and Character constants
|
|
53 " Highlight special characters (those which have a escape) differently
|
|
54 syn case ignore
|
|
55 syn region msmessagesLangEntry start=/\<Language\>\s*=\s*\S\+\s*$/hs=e+1 end=/^\./ contains=msmessagesFormat,msmessagesLangEntryEnd,msmessagesLanguage keepend
|
|
56 syn match msmessagesLanguage /\<Language\(\s*=\)\@=/ contained
|
|
57 syn match msmessagesLangEntryEnd display /^\./ contained
|
|
58 syn case match
|
|
59 syn match msmessagesFormat display /%[1-9]\d\?\(![-+0 #]*\d*\(\.\d\+\)\?\(h\|l\|ll\|I\|I32\|I64\)\?[aAcCdeEfgGinopsSuxX]!\)\?/ contained
|
|
60 syn match msmessagesFormat display /%[0.%\\br]/ contained
|
|
61 syn match msmessagesFormat display /%!\(\s\)\@=/ contained
|
|
62
|
|
63 " Integer number, or floating point number without a dot and with "f".
|
|
64 " Copied from c.vim
|
|
65 syn case ignore
|
|
66 "(long) integer
|
|
67 syn match msmessagesNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
|
|
68 "hex number
|
|
69 syn match msmessagesNumber display contained "\<0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
|
|
70 " Flag the first zero of an octal number as something special
|
|
71 syn match msmessagesOctal display contained "\<0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=msmessagesOctalZero
|
|
72 syn match msmessagesOctalZero display contained "\<0"
|
|
73 " flag an octal number with wrong digits
|
|
74 syn match msmessagesOctalError display contained "\<0\o*[89]\d*"
|
|
75 syn match msmessagesFloat display contained "\d\+f"
|
|
76 "floating point number, with dot, optional exponent
|
|
77 syn match msmessagesFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
|
|
78 "floating point number, starting with a dot, optional exponent
|
|
79 syn match msmessagesFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
|
|
80 "floating point number, without dot, with exponent
|
|
81 syn match msmessagesFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
|
|
82 "hexadecimal floating point number, optional leading digits, with dot, with exponent
|
|
83 syn match msmessagesFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
|
|
84 "hexadecimal floating point number, with leading digits, optional dot, with exponent
|
|
85 syn match msmessagesFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
|
|
86
|
|
87 " Types (used in MessageIdTypedef statement)
|
|
88 syn case match
|
|
89 syn keyword msmessagesType int long short char
|
|
90 syn keyword msmessagesType signed unsigned
|
|
91 syn keyword msmessagesType size_t ssize_t sig_atomic_t
|
|
92 syn keyword msmessagesType int8_t int16_t int32_t int64_t
|
|
93 syn keyword msmessagesType uint8_t uint16_t uint32_t uint64_t
|
|
94 syn keyword msmessagesType int_least8_t int_least16_t int_least32_t int_least64_t
|
|
95 syn keyword msmessagesType uint_least8_t uint_least16_t uint_least32_t uint_least64_t
|
|
96 syn keyword msmessagesType int_fast8_t int_fast16_t int_fast32_t int_fast64_t
|
|
97 syn keyword msmessagesType uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t
|
|
98 syn keyword msmessagesType intptr_t uintptr_t
|
|
99 syn keyword msmessagesType intmax_t uintmax_t
|
|
100 " Add some Windows datatypes that will be common in msmessages files
|
|
101 syn keyword msmessagesType BYTE CHAR SHORT SIZE_T SSIZE_T TBYTE TCHAR UCHAR USHORT
|
|
102 syn keyword msmessagesType DWORD DWORDLONG DWORD32 DWORD64
|
|
103 syn keyword msmessagesType INT INT32 INT64 UINT UINT32 UINT64
|
|
104 syn keyword msmessagesType LONG LONGLONG LONG32 LONG64
|
|
105 syn keyword msmessagesType ULONG ULONGLONG ULONG32 ULONG64
|
|
106
|
|
107 " Sync to language entries, since they should be most common
|
|
108 syn sync match msmessagesLangSync grouphere msmessagesLangEntry "\<Language\s*="
|
|
109 syn sync match msmessagesLangEndSync grouphere NONE "^\."
|
|
110
|
|
111 " Define the default highlighting.
|
|
112 hi def link msmessagesNumber Number
|
|
113 hi def link msmessagesOctal Number
|
|
114 hi def link msmessagesFloat Float
|
|
115 hi def link msmessagesOctalError msmessagesError
|
|
116 hi def link msmessagesSetError msmessagesError
|
|
117 hi def link msmessagesError Error
|
|
118 hi def link msmessagesLangEntry String
|
|
119 hi def link msmessagesLangEntryEnd Special
|
|
120 hi def link msmessagesComment Comment
|
|
121 hi def link msmessagesFormat msmessagesSpecial
|
|
122 hi def link msmessagesSpecial SpecialChar
|
|
123
|
|
124 hi def link msmessagesType Type
|
|
125 hi def link msmessagesIdentifier Identifier
|
|
126 hi def link msmessagesLanguage msmessagesIdentifier
|
|
127 hi def link msmessagesName msmessagesIdentifier
|
|
128 hi def link msmessagesNameDef Macro
|
|
129 hi def link msmessagesIdentDef Macro
|
|
130 hi def link msmessagesValSep Special
|
|
131 hi def link msmessagesNameErr Error
|
|
132
|
|
133 let b:current_syntax = "msmessages"
|
|
134
|
|
135 " vim: ts=8
|