]> git.r.bdr.sh - rbdr/dotfiles/blob - vim/syntax/puppet.vim
Turn off the blur
[rbdr/dotfiles] / vim / syntax / puppet.vim
1 " puppet syntax file
2 " Filename: puppet.vim
3 " Language: puppet configuration file
4 " Maintainer: Luke Kanies <luke@madstop.com>
5 " URL:
6 " Last Change:
7 " Version:
8 "
9
10 " Copied from the cfengine, ruby, and perl syntax files
11 " For version 5.x: Clear all syntax items
12 " For version 6.x: Quit when a syntax file was already loaded
13 if version < 600
14 syntax clear
15 elseif exists("b:current_syntax")
16 finish
17 endif
18
19 " match class/definition/node declarations
20 syn region puppetDefine start="^\s*\(class\|define\|node\)\s" end="{" contains=puppetDefType,puppetDefName,puppetDefArguments,puppetNodeRe
21 syn keyword puppetDefType class define node inherits contained
22 syn region puppetDefArguments start="(" end=")" contained contains=puppetArgument,puppetString
23 syn match puppetArgument "\w\+" contained
24 syn match puppetArgument "\$\w\+" contained
25 syn match puppetArgument "'[^']+'" contained
26 syn match puppetArgument '"[^"]+"' contained
27 syn match puppetDefName "\w\+" contained
28 syn match puppetNodeRe "/.*/" contained
29
30 " match 'foo' in 'class foo { ...'
31 " match 'foo::bar' in 'class foo::bar { ...'
32 " match 'Foo::Bar' in 'Foo::Bar["..."]
33 "FIXME: "Foo-bar" doesn't get highlighted as expected, although "foo-bar" does.
34 syn match puppetInstance "[A-Za-z0-9_-]\+\(::[A-Za-z0-9_-]\+\)*\s*{" contains=puppetTypeName,puppetTypeDefault
35 syn match puppetInstance "[A-Z][a-z_-]\+\(::[A-Z][a-z_-]\+\)*\s*[[{]" contains=puppetTypeName,puppetTypeDefault
36 syn match puppetInstance "[A-Z][a-z_-]\+\(::[A-Z][a-z_-]\+\)*\s*<\?<|" contains=puppetTypeName,puppetTypeDefault
37 syn match puppetTypeName "[a-z]\w*" contained
38 syn match puppetTypeDefault "[A-Z]\w*" contained
39
40 " match 'foo' in 'foo => "bar"'
41 syn match puppetParam "\w\+\s*[=+]>" contains=puppetParamName
42 syn match puppetParamName "\w\+" contained
43
44 " match 'present' in 'ensure => present'
45 " match '2755' in 'mode => 2755'
46 " don't match 'bar' in 'foo => bar'
47 syn match puppetParam "\w\+\s*[=+]>\s*[a-z0-9]\+" contains=puppetParamString,puppetParamName
48 syn match puppetParamString "[=+]>\s*\w\+" contains=puppetParamKeyword,puppetParamSpecial,puppetParamDigits contained
49 syn keyword puppetParamKeyword present absent purged latest installed running stopped mounted unmounted role configured file directory link contained
50 syn keyword puppetParamSpecial true false undef contained
51 syn match puppetParamDigits "[0-9]\+"
52
53 " match 'template' in 'content => template("...")'
54 syn match puppetParam "\w\+\s*[=+]>\s*\w\+\s*(" contains=puppetFunction,puppetParamName
55 " statements
56 syn region puppetFunction start="^\s*\(alert\|crit\|debug\|emerg\|err\|fail\|include\|info\|notice\|realize\|require\|search\|tag\|warning\)\s*(" end=")" contained contains=puppetString
57 " rvalues
58 syn region puppetFunction start="^\s*\(defined\|file\|fqdn_rand\|generate\|inline_template\|regsubst\|sha1\|shellquote\|split\|sprintf\|tagged\|template\|versioncmp\)\s*(" end=")" contained contains=puppetString
59
60 syn match puppetVariable "$[a-zA-Z0-9_:]\+"
61 syn match puppetVariable "${[a-zA-Z0-9_:]\+}"
62
63 " match anything between simple/double quotes.
64 " don't match variables if preceded by a backslash.
65 syn region puppetString start=+'+ skip=+\\\\\|\\'+ end=+'+
66 syn region puppetString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=puppetVariable,puppetNotVariable
67 syn match puppetString "/[^/]*/"
68 syn match puppetNotVariable "\\$\w\+" contained
69 syn match puppetNotVariable "\\${\w\+}" contained
70
71 syn keyword puppetKeyword import inherits include
72 syn keyword puppetControl case default if else elsif
73 syn keyword puppetSpecial true false undef
74
75 " comments last overriding everything else
76 syn match puppetComment "\s*#.*$" contains=puppetTodo
77 syn region puppetComment start="/\*" end="\*/" contains=puppetTodo extend
78 syn keyword puppetTodo TODO NOTE FIXME XXX BUG HACK contained
79
80 " Define the default highlighting.
81 " For version 5.7 and earlier: only when not done already
82 " For version 5.8 and later: only when an item doesn't have highlighting yet
83 if version >= 508 || !exists("did_puppet_syn_inits")
84 if version < 508
85 let did_puppet_syn_inits = 1
86 command -nargs=+ HiLink hi link <args>
87 else
88 command -nargs=+ HiLink hi def link <args>
89 endif
90
91 HiLink puppetVariable Identifier
92 HiLink puppetType Identifier
93 HiLink puppetKeyword Define
94 HiLink puppetComment Comment
95 HiLink puppetString String
96 HiLink puppetParamKeyword String
97 HiLink puppetParamDigits String
98 HiLink puppetNotVariable String
99 HiLink puppetParamSpecial Special
100 HiLink puppetSpecial Special
101 HiLink puppetTodo Todo
102 HiLink puppetControl Statement
103 HiLink puppetDefType Define
104 HiLink puppetDefName Type
105 HiLink puppetNodeRe Type
106 HiLink puppetTypeName Statement
107 HiLink puppetTypeDefault Type
108 HiLink puppetParamName Identifier
109 HiLink puppetArgument Identifier
110 HiLink puppetFunction Function
111
112 delcommand HiLink
113 endif
114
115 let b:current_syntax = "puppet"
116 set iskeyword=-,:,@,48-57,_,192-255
117