Mercurial > vim
annotate runtime/syntax/dosbatch.vim @ 33080:51b4577d57bf
Added tag v9.0.1826 for changeset 5f201b734cb7b114a411a339a895d25ebecf7262
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 30 Aug 2023 19:45:05 +0200 |
parents | a9b5ffbc0428 |
children | 9c674ef89d9d |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
32004 | 2 " Language: MS-DOS/Windows batch file (with NT command extensions) |
3 " Maintainer: Mike Williams <mrmrdubya@gmail.com> | |
7 | 4 " Filenames: *.bat |
32004 | 5 " Last Change: 12th February 2023 |
7 | 6 " |
7 " Options Flags: | |
8 " dosbatch_cmdextversion - 1 = Windows NT, 2 = Windows 2000 [default] | |
32004 | 9 " dosbatch_colons_comment - any value to treat :: as comment line |
7 | 10 " |
11 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2034
diff
changeset
|
12 " quit when a syntax file was already loaded |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2034
diff
changeset
|
13 if exists("b:current_syntax") |
7 | 14 finish |
15 endif | |
16 | |
17 " Set default highlighting to Win2k | |
18 if !exists("dosbatch_cmdextversion") | |
19 let dosbatch_cmdextversion = 2 | |
20 endif | |
21 | |
22 " DOS bat files are case insensitive but case preserving! | |
23 syn case ignore | |
24 | |
25 syn keyword dosbatchTodo contained TODO | |
26 | |
27 " Dosbat keywords | |
28 syn keyword dosbatchStatement goto call exit | |
29 syn keyword dosbatchConditional if else | |
30 syn keyword dosbatchRepeat for | |
31 | |
32 " Some operators - first lot are case sensitive! | |
33 syn case match | |
34 syn keyword dosbatchOperator EQU NEQ LSS LEQ GTR GEQ | |
35 syn case ignore | |
2034 | 36 syn match dosbatchOperator "\s[-+\*/%!~]\s" |
7 | 37 syn match dosbatchOperator "=" |
38 syn match dosbatchOperator "[-+\*/%]=" | |
39 syn match dosbatchOperator "\s\(&\||\|^\|<<\|>>\)=\=\s" | |
40 syn match dosbatchIfOperator "if\s\+\(\(not\)\=\s\+\)\=\(exist\|defined\|errorlevel\|cmdextversion\)\="lc=2 | |
41 | |
42 " String - using "'s is a convenience rather than a requirement outside of FOR | |
1623 | 43 syn match dosbatchString "\"[^"]*\"" contains=dosbatchVariable,dosBatchArgument,dosbatchSpecialChar,@dosbatchNumber,@Spell |
44 syn match dosbatchString "\<echo\([^)>|]\|\^\@<=[)>|]\)*"lc=4 contains=dosbatchVariable,dosbatchArgument,dosbatchSpecialChar,@dosbatchNumber,@Spell | |
7 | 45 syn match dosbatchEchoOperator "\<echo\s\+\(on\|off\)\s*$"lc=4 |
46 | |
47 " For embedded commands | |
48 syn match dosbatchCmd "(\s*'[^']*'"lc=1 contains=dosbatchString,dosbatchVariable,dosBatchArgument,@dosbatchNumber,dosbatchImplicit,dosbatchStatement,dosbatchConditional,dosbatchRepeat,dosbatchOperator | |
49 | |
50 " Numbers - surround with ws to not include in dir and filenames | |
2034 | 51 syn match dosbatchInteger "[[:space:]=(/:,!~-]\d\+"lc=1 |
52 syn match dosbatchHex "[[:space:]=(/:,!~-]0x\x\+"lc=1 | |
53 syn match dosbatchBinary "[[:space:]=(/:,!~-]0b[01]\+"lc=1 | |
54 syn match dosbatchOctal "[[:space:]=(/:,!~-]0\o\+"lc=1 | |
7 | 55 syn cluster dosbatchNumber contains=dosbatchInteger,dosbatchHex,dosbatchBinary,dosbatchOctal |
56 | |
57 " Command line switches | |
58 syn match dosbatchSwitch "/\(\a\+\|?\)" | |
59 | |
60 " Various special escaped char formats | |
61 syn match dosbatchSpecialChar "\^[&|()<>^]" | |
62 syn match dosbatchSpecialChar "\$[a-hl-npqstv_$+]" | |
63 syn match dosbatchSpecialChar "%%" | |
64 | |
65 " Environment variables | |
66 syn match dosbatchIdentifier contained "\s\h\w*\>" | |
67 syn match dosbatchVariable "%\h\w*%" | |
68 syn match dosbatchVariable "%\h\w*:\*\=[^=]*=[^%]*%" | |
2034 | 69 syn match dosbatchVariable "%\h\w*:\~[-]\=\d\+\(,[-]\=\d\+\)\=%" contains=dosbatchInteger |
7 | 70 syn match dosbatchVariable "!\h\w*!" |
2034 | 71 syn match dosbatchVariable "!\h\w*:\*\=[^=]*=[^!]*!" |
72 syn match dosbatchVariable "!\h\w*:\~[-]\=\d\+\(,[-]\=\d\+\)\=!" contains=dosbatchInteger | |
7 | 73 syn match dosbatchSet "\s\h\w*[+-]\==\{-1}" contains=dosbatchIdentifier,dosbatchOperator |
74 | |
75 " Args to bat files and for loops, etc | |
76 syn match dosbatchArgument "%\(\d\|\*\)" | |
2034 | 77 syn match dosbatchArgument "%[a-z]\>" |
7 | 78 if dosbatch_cmdextversion == 1 |
79 syn match dosbatchArgument "%\~[fdpnxs]\+\(\($PATH:\)\=[a-z]\|\d\)\>" | |
80 else | |
81 syn match dosbatchArgument "%\~[fdpnxsatz]\+\(\($PATH:\)\=[a-z]\|\d\)\>" | |
82 endif | |
83 | |
84 " Line labels | |
85 syn match dosbatchLabel "^\s*:\s*\h\w*\>" | |
86 syn match dosbatchLabel "\<\(goto\|call\)\s\+:\h\w*\>"lc=4 | |
87 syn match dosbatchLabel "\<goto\s\+\h\w*\>"lc=4 | |
88 syn match dosbatchLabel ":\h\w*\>" | |
89 | |
90 " Comments - usual rem but also two colons as first non-space is an idiom | |
1623 | 91 syn match dosbatchComment "^rem\($\|\s.*$\)"lc=3 contains=dosbatchTodo,dosbatchSpecialChar,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell |
2034 | 92 syn match dosbatchComment "^@rem\($\|\s.*$\)"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell |
1623 | 93 syn match dosbatchComment "\srem\($\|\s.*$\)"lc=4 contains=dosbatchTodo,dosbatchSpecialChar,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell |
2034 | 94 syn match dosbatchComment "\s@rem\($\|\s.*$\)"lc=5 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell |
32004 | 95 if exists("dosbatch_colons_comment") |
96 syn match dosbatchComment "\s*:\s*:.*$" contains=dosbatchTodo,dosbatchSpecialChar,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell | |
97 else | |
98 syn match dosbatchError "\s*:\s*:.*$" | |
99 endif | |
7 | 100 |
101 " Comments in ()'s - still to handle spaces before rem | |
1623 | 102 syn match dosbatchComment "(rem\([^)]\|\^\@<=)\)*"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell |
7 | 103 |
104 syn keyword dosbatchImplicit append assoc at attrib break cacls cd chcp chdir | |
105 syn keyword dosbatchImplicit chkdsk chkntfs cls cmd color comp compact convert copy | |
106 syn keyword dosbatchImplicit date del dir diskcomp diskcopy doskey echo endlocal | |
107 syn keyword dosbatchImplicit erase fc find findstr format ftype | |
108 syn keyword dosbatchImplicit graftabl help keyb label md mkdir mode more move | |
109 syn keyword dosbatchImplicit path pause popd print prompt pushd rd recover rem | |
110 syn keyword dosbatchImplicit ren rename replace restore rmdir set setlocal shift | |
111 syn keyword dosbatchImplicit sort start subst time title tree type ver verify | |
112 syn keyword dosbatchImplicit vol xcopy | |
113 | |
114 " Define the default highlighting. | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2034
diff
changeset
|
115 " Only when an item doesn't have highlighting yet |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2034
diff
changeset
|
116 |
32004 | 117 hi def link dosbatchTodo Todo |
118 hi def link dosbatchError Error | |
7 | 119 |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
120 hi def link dosbatchStatement Statement |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
121 hi def link dosbatchCommands dosbatchStatement |
32004 | 122 hi def link dosbatchLabel Label |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
123 hi def link dosbatchConditional Conditional |
32004 | 124 hi def link dosbatchRepeat Repeat |
7 | 125 |
32004 | 126 hi def link dosbatchOperator Operator |
127 hi def link dosbatchEchoOperator dosbatchOperator | |
128 hi def link dosbatchIfOperator dosbatchOperator | |
7 | 129 |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
130 hi def link dosbatchArgument Identifier |
32004 | 131 hi def link dosbatchIdentifier Identifier |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
132 hi def link dosbatchVariable dosbatchIdentifier |
7 | 133 |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
134 hi def link dosbatchSpecialChar SpecialChar |
32004 | 135 hi def link dosbatchString String |
136 hi def link dosbatchNumber Number | |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
137 hi def link dosbatchInteger dosbatchNumber |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
138 hi def link dosbatchHex dosbatchNumber |
32004 | 139 hi def link dosbatchBinary dosbatchNumber |
140 hi def link dosbatchOctal dosbatchNumber | |
7 | 141 |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
142 hi def link dosbatchComment Comment |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
143 hi def link dosbatchImplicit Function |
7 | 144 |
32004 | 145 hi def link dosbatchSwitch Special |
7 | 146 |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
147 hi def link dosbatchCmd PreProc |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
2034
diff
changeset
|
148 |
7 | 149 |
150 let b:current_syntax = "dosbatch" | |
151 | |
152 " vim: ts=8 |