if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'puppet') != -1 finish endif " Language: Puppet " Maintainer: Voxpupuli " URL: https://github.com/voxpupuli/vim-puppet " " Thanks to Doug Kearns who maintains the vim syntax file for Ruby. Many constructs, including interpolation " and heredoc was copied from ruby and then modified to comply with Puppet syntax. " Prelude {{{1 if exists("b:current_syntax") finish endif " this file uses line continuations let s:cpo_sav = &cpo set cpo&vim syn cluster puppetNotTop contains=@puppetExtendedStringSpecial,@puppetRegexpSpecial,@puppetDeclaration,puppetConditional,puppetExceptional,puppetMethodExceptional,puppetTodo syn match puppetSpaceError display excludenl "\s\+$" syn match puppetSpaceError display " \+\t"me=e-1 " one character operators syn match puppetOperator "[=><+/*%!.|@:,;?~-]" " two character operators syn match puppetOperator "+=\|-=\|==\|!=\|=\~\|!\~\|>=\|<=\|<-\|<\~\|=>\|+>\|->\|\~>\|<<\||>\|@@" " three character operators syn match puppetOperator "<<|\||>>" syn region puppetBracketOperator matchgroup=puppetDelimiter start="\[\s*" end="\s*]" contains=ALLBUT,@puppetNotTop syn region puppetBraceOperator matchgroup=puppetDelimiter start="{\s*" end="\s*}" contains=ALLBUT,@puppetNotTop syn region puppetParenOperator matchgroup=puppetDelimiter start="(\s*" end="\s*)" contains=ALLBUT,@puppetNotTop " Expression Substitution and Backslash Notation {{{1 syn match puppetStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display syn match puppetStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display syn match puppetQuoteEscape "\\[\\']" contained display syn region puppetInterpolation matchgroup=puppetInterpolationDelimiter start="${" end="}" contained contains=ALLBUT,@puppetNotTop syn match puppetInterpolation "$\w\+" display contained contains=puppetInterpolationDelimiter,puppetVariable syn match puppetInterpolationDelimiter "$\ze\$\w\+" display contained syn match puppetInterpolation "$\$\%(-\w\|\W\)" display contained contains=puppetInterpolationDelimiter,puppetVariable,puppetInvalidVariable syn match puppetInterpolationDelimiter "$\ze\$\%(-\w\|\W\)" display contained syn region puppetNoInterpolation start="\\${" end="}" contained syn match puppetNoInterpolation "\\${" display contained syn match puppetNoInterpolation "\\$\w\+" display contained syn match puppetDelimiterEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE syn region puppetNestedParentheses start="(" skip="\\\\\|\\)" matchgroup=puppetString end=")" transparent contained syn region puppetNestedCurlyBraces start="{" skip="\\\\\|\\}" matchgroup=puppetString end="}" transparent contained syn region puppetNestedAngleBrackets start="<" skip="\\\\\|\\>" matchgroup=puppetString end=">" transparent contained syn region puppetNestedSquareBrackets start="\[" skip="\\\\\|\\\]" matchgroup=puppetString end="\]" transparent contained " Regular Expression Metacharacters {{{1 " These are mostly Oniguruma ready syn region puppetRegexpComment matchgroup=puppetRegexpSpecial start="(?#" skip="\\)" end=")" contained syn region puppetRegexpParens matchgroup=puppetRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\)" end=")" contained transparent contains=@puppetRegexpSpecial syn region puppetRegexpBrackets matchgroup=puppetRegexpCharClass start="\[\^\=" skip="\\\]" end="\]" contained transparent contains=puppetStringEscape,puppetRegexpEscape,puppetRegexpCharClass oneline syn match puppetRegexpCharClass "\\[DdHhSsWw]" contained display syn match puppetRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\):\]" contained syn match puppetRegexpEscape "\\[].*?+^$|\\/(){}[]" contained syn match puppetRegexpQuantifier "[*?+][?+]\=" contained display syn match puppetRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display syn match puppetRegexpAnchor "[$^]\|\\[ABbGZz]" contained display syn match puppetRegexpDot "\." contained display syn match puppetRegexpSpecial "|" contained display syn match puppetRegexpSpecial "\\[1-9]\d\=\d\@!" contained display syn match puppetRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display syn match puppetRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display syn match puppetRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display syn match puppetRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display syn cluster puppetStringSpecial contains=puppetInterpolation,puppetNoInterpolation,puppetStringEscape syn cluster puppetExtendedStringSpecial contains=@puppetStringSpecial,puppetNestedParentheses,puppetNestedCurlyBraces,puppetNestedAngleBrackets,puppetNestedSquareBrackets syn cluster puppetRegexpSpecial contains=puppetRegexpSpecial,puppetRegexpEscape,puppetRegexpBrackets,puppetRegexpCharClass,puppetRegexpDot,puppetRegexpQuantifier,puppetRegexpAnchor,puppetRegexpParens,puppetRegexpComment syn match puppetInteger "\%(\%(\w\|[]})\"']\s*\)\@" display syn match puppetInteger "\%(\%(\w\|[]})\"']\s*\)\@" display syn match puppetInteger "\%(\%(\w\|[]})\"']\s*\)\@" display syn match puppetInteger "\%(\%(\w\|[]})\"']\s*\)\@" display syn match puppetFloat "\%(\%(\w\|[]})\"']\s*\)\@" display syn match puppetFloat "\%(\%(\w\|[]})\"']\s*\)\@" display syn match puppetVariable "$\%(::\)\=\w\+\%(::\w\+\)*" display syn match puppetName "\%(::\)\=[a-z]\w*\%(::[a-z]\w*\)*" display syn match puppetType "\%(::\)\=[A-Z]\w*\%(::[A-Z]\w*\)*" display syn match puppetWord "\%(\%(::\)\=\%(_[\w-]*\w\+\)\|\%([a-z]\%(\w*-\)\+\w\+\)\)\+" display " bad name containing combinations of segment starting with lower case and segement starting with upper case (or vice versa) syn match puppetNameBad "\%(::\)\=\%(\w\+::\)*\%(\%([a-z]\w*::[A-Z]\w*\)\|\%([A-Z]\w*::[a-z]\w*\)\)\%(::\w\+\)*" display syn cluster puppetNameOrType contains=puppetVariable,puppetName,puppetType,puppetWord,puppetNameBad syn keyword puppetControl case and or in syn keyword puppetKeyword class define inherits node undef function type attr private syn keyword puppetKeyword application consumes produces site syn keyword puppetKeyword present absent purged latest installed running stopped mounted unmounted role configured file directory link on_failure contained syn keyword puppetConstant default undef syn keyword puppetConditional if else elsif unless syn keyword puppetBoolean true false " Core functions syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" syn match puppetFunction "\" " Stdlib functions syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetStdLibFunction "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" syn match puppetType "\" " Normal String {{{1 syn region puppetString matchgroup=puppetStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@puppetStringSpecial syn region puppetString matchgroup=puppetStringDelimiter start="'" end="'" skip="\\\\\|\\'" contains=puppetQuoteEscape " Normal Regular Expression {{{1 syn region puppetRegexp matchgroup=puppetRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/" skip="\\\\\|\\/" contains=@puppetRegexpSpecial syn region puppetRegexp matchgroup=puppetRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/" skip="\\\\\|\\/" contains=@puppetRegexpSpecial " Here Document {{{1 syn region puppetHeredocStart matchgroup=puppetStringDelimiter start=+@(\s*\%("[^"]\+"\|\w\+\)\%(/[nrtsuL$\\]*\)\=)+ end=+$+ oneline contains=ALLBUT,@puppetNotTop syn region puppetString start=+@(\s*"\z([^"]\+\)"\%(/[nrtsuL$\\]*\)\=+hs=s+2 matchgroup=puppetStringDelimiter end=+^\s*|\=\s*-\=\s*\zs\z1$+ contains=puppetHeredocStart,@puppetStringSpecial keepend syn region puppetString start=+@(\s*\z(\w\+\)\%(/[nrtsuL$\\]*\)\=+hs=s+2 matchgroup=puppetStringDelimiter end=+^\s*|\=\s*-\=\s*\zs\z1$+ contains=puppetHeredocStart keepend " comments last overriding everything else syn match puppetComment "\s*#.*$" contains=puppetTodo,@Spell syn region puppetComment start="/\*" end="\*/" contains=puppetTodo,@Spell extend syn keyword puppetTodo TODO NOTE FIXME XXX BUG HACK contained " Define the default highlighting. command -nargs=+ HiLink hi def link HiLink puppetRegexp puppetConstant HiLink puppetStdLibFunction puppetFunction HiLink puppetNoInterpolation puppetString HiLink puppetFunction Function HiLink puppetOperator Operator HiLink puppetString String HiLink puppetWord String HiLink puppetFloat Float HiLink puppetInteger Number HiLink puppetBoolean Boolean HiLink puppetName puppetIdentifier HiLink puppetNameBad Error HiLink puppetVariable puppetIdentifier HiLink puppetIdentifier Identifier HiLink puppetType Type HiLink puppetConditional Conditional HiLink puppetConstant Constant HiLink puppetControl Statement HiLink puppetKeyword Keyword HiLink puppetStringDelimiter Delimiter HiLink puppetDelimiter Delimiter HiLink puppetTodo Todo HiLink puppetComment Comment delcommand HiLink let b:current_syntax = "puppet"