From 071d4279d6ab81b7187b48f3a0fc61e587b6db6c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 13 Jun 2004 20:20:40 +0000 Subject: updated for version 7.0001 --- runtime/syntax/dosbatch.vim | 158 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 runtime/syntax/dosbatch.vim (limited to 'runtime/syntax/dosbatch.vim') diff --git a/runtime/syntax/dosbatch.vim b/runtime/syntax/dosbatch.vim new file mode 100644 index 000000000..e27310cc9 --- /dev/null +++ b/runtime/syntax/dosbatch.vim @@ -0,0 +1,158 @@ +" Vim syntax file +" Language: MSDOS batch file (with NT command extensions) +" Maintainer: Mike Williams +" Filenames: *.bat +" Last Change: 16th March 2004 +" Web Page: http://www.eandem.co.uk/mrw/vim +" +" Options Flags: +" dosbatch_cmdextversion - 1 = Windows NT, 2 = Windows 2000 [default] +" + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Set default highlighting to Win2k +if !exists("dosbatch_cmdextversion") + let dosbatch_cmdextversion = 2 +endif + +" DOS bat files are case insensitive but case preserving! +syn case ignore + +syn keyword dosbatchTodo contained TODO + +" Dosbat keywords +syn keyword dosbatchStatement goto call exit +syn keyword dosbatchConditional if else +syn keyword dosbatchRepeat for + +" Some operators - first lot are case sensitive! +syn case match +syn keyword dosbatchOperator EQU NEQ LSS LEQ GTR GEQ +syn case ignore +syn match dosbatchOperator "\s[-+\*/%]\s" +syn match dosbatchOperator "=" +syn match dosbatchOperator "[-+\*/%]=" +syn match dosbatchOperator "\s\(&\||\|^\|<<\|>>\)=\=\s" +syn match dosbatchIfOperator "if\s\+\(\(not\)\=\s\+\)\=\(exist\|defined\|errorlevel\|cmdextversion\)\="lc=2 + +" String - using "'s is a convenience rather than a requirement outside of FOR +syn match dosbatchString "\"[^"]*\"" contains=dosbatchVariable,dosBatchArgument,@dosbatchNumber +syn match dosbatchString "\|]*"lc=4 contains=dosbatchVariable,dosbatchArgument,@dosbatchNumber +syn match dosbatchEchoOperator "\^]" +syn match dosbatchSpecialChar "\$[a-hl-npqstv_$+]" +syn match dosbatchSpecialChar "%%" + +" Environment variables +syn match dosbatchIdentifier contained "\s\h\w*\>" +syn match dosbatchVariable "%\h\w*%" +syn match dosbatchVariable "%\h\w*:\*\=[^=]*=[^%]*%" +syn match dosbatchVariable "%\h\w*:\~\d\+,\d\+%" contains=dosbatchInteger +syn match dosbatchVariable "!\h\w*!" +syn match dosbatchVariable "!\h\w*:\*\=[^=]*=[^%]*!" +syn match dosbatchVariable "!\h\w*:\~\d\+,\d\+!" contains=dosbatchInteger +syn match dosbatchSet "\s\h\w*[+-]\==\{-1}" contains=dosbatchIdentifier,dosbatchOperator + +" Args to bat files and for loops, etc +syn match dosbatchArgument "%\(\d\|\*\)" +syn match dosbatchArgument "%%[a-z]\>" +if dosbatch_cmdextversion == 1 + syn match dosbatchArgument "%\~[fdpnxs]\+\(\($PATH:\)\=[a-z]\|\d\)\>" +else + syn match dosbatchArgument "%\~[fdpnxsatz]\+\(\($PATH:\)\=[a-z]\|\d\)\>" +endif + +" Line labels +syn match dosbatchLabel "^\s*:\s*\h\w*\>" +syn match dosbatchLabel "\<\(goto\|call\)\s\+:\h\w*\>"lc=4 +syn match dosbatchLabel "\"lc=4 +syn match dosbatchLabel ":\h\w*\>" + +" Comments - usual rem but also two colons as first non-space is an idiom +syn match dosbatchComment "^rem\($\|\s.*$\)"lc=3 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument +syn match dosbatchComment "\srem\($\|\s.*$\)"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument +syn match dosbatchComment "\s*:\s*:.*$" contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument + +" Comments in ()'s - still to handle spaces before rem +syn match dosbatchComment "(rem[^)]*"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument + +syn keyword dosbatchImplicit append assoc at attrib break cacls cd chcp chdir +syn keyword dosbatchImplicit chkdsk chkntfs cls cmd color comp compact convert copy +syn keyword dosbatchImplicit date del dir diskcomp diskcopy doskey echo endlocal +syn keyword dosbatchImplicit erase fc find findstr format ftype +syn keyword dosbatchImplicit graftabl help keyb label md mkdir mode more move +syn keyword dosbatchImplicit path pause popd print prompt pushd rd recover rem +syn keyword dosbatchImplicit ren rename replace restore rmdir set setlocal shift +syn keyword dosbatchImplicit sort start subst time title tree type ver verify +syn keyword dosbatchImplicit vol xcopy + +" 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_dosbatch_syntax_inits") + if version < 508 + let did_dosbatch_syntax_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + HiLink dosbatchTodo Todo + + HiLink dosbatchStatement Statement + HiLink dosbatchCommands dosbatchStatement + HiLink dosbatchLabel Label + HiLink dosbatchConditional Conditional + HiLink dosbatchRepeat Repeat + + HiLink dosbatchOperator Operator + HiLink dosbatchEchoOperator dosbatchOperator + HiLink dosbatchIfOperator dosbatchOperator + + HiLink dosbatchArgument Identifier + HiLink dosbatchIdentifier Identifier + HiLink dosbatchVariable dosbatchIdentifier + + HiLink dosbatchSpecialChar SpecialChar + HiLink dosbatchString String + HiLink dosbatchNumber Number + HiLink dosbatchInteger dosbatchNumber + HiLink dosbatchHex dosbatchNumber + HiLink dosbatchBinary dosbatchNumber + HiLink dosbatchOctal dosbatchNumber + + HiLink dosbatchComment Comment + HiLink dosbatchImplicit Function + + HiLink dosbatchSwitch Special + + HiLink dosbatchCmd PreProc + + delcommand HiLink +endif + +let b:current_syntax = "dosbatch" + +" vim: ts=8 -- cgit v1.2.1