]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - vim/syntax/puppet.vim
Update the stuff
[rbdr/dotfiles] / vim / syntax / puppet.vim
... / ...
CommitLineData
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
13if version < 600
14 syntax clear
15elseif exists("b:current_syntax")
16 finish
17endif
18
19" match class/definition/node declarations
20syn region puppetDefine start="^\s*\(class\|define\|node\)\s" end="{" contains=puppetDefType,puppetDefName,puppetDefArguments,puppetNodeRe
21syn keyword puppetDefType class define node inherits contained
22syn region puppetDefArguments start="(" end=")" contained contains=puppetArgument,puppetString
23syn match puppetArgument "\w\+" contained
24syn match puppetArgument "\$\w\+" contained
25syn match puppetArgument "'[^']+'" contained
26syn match puppetArgument '"[^"]+"' contained
27syn match puppetDefName "\w\+" contained
28syn 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.
34syn match puppetInstance "[A-Za-z0-9_-]\+\(::[A-Za-z0-9_-]\+\)*\s*{" contains=puppetTypeName,puppetTypeDefault
35syn match puppetInstance "[A-Z][a-z_-]\+\(::[A-Z][a-z_-]\+\)*\s*[[{]" contains=puppetTypeName,puppetTypeDefault
36syn match puppetInstance "[A-Z][a-z_-]\+\(::[A-Z][a-z_-]\+\)*\s*<\?<|" contains=puppetTypeName,puppetTypeDefault
37syn match puppetTypeName "[a-z]\w*" contained
38syn match puppetTypeDefault "[A-Z]\w*" contained
39
40" match 'foo' in 'foo => "bar"'
41syn match puppetParam "\w\+\s*[=+]>" contains=puppetParamName
42syn 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'
47syn match puppetParam "\w\+\s*[=+]>\s*[a-z0-9]\+" contains=puppetParamString,puppetParamName
48syn match puppetParamString "[=+]>\s*\w\+" contains=puppetParamKeyword,puppetParamSpecial,puppetParamDigits contained
49syn keyword puppetParamKeyword present absent purged latest installed running stopped mounted unmounted role configured file directory link contained
50syn keyword puppetParamSpecial true false undef contained
51syn match puppetParamDigits "[0-9]\+"
52
53" match 'template' in 'content => template("...")'
54syn match puppetParam "\w\+\s*[=+]>\s*\w\+\s*(" contains=puppetFunction,puppetParamName
55" statements
56syn 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
58syn 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
60syn match puppetVariable "$[a-zA-Z0-9_:]\+"
61syn match puppetVariable "${[a-zA-Z0-9_:]\+}"
62
63" match anything between simple/double quotes.
64" don't match variables if preceded by a backslash.
65syn region puppetString start=+'+ skip=+\\\\\|\\'+ end=+'+
66syn region puppetString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=puppetVariable,puppetNotVariable
67syn match puppetString "/[^/]*/"
68syn match puppetNotVariable "\\$\w\+" contained
69syn match puppetNotVariable "\\${\w\+}" contained
70
71syn keyword puppetKeyword import inherits include
72syn keyword puppetControl case default if else elsif
73syn keyword puppetSpecial true false undef
74
75" comments last overriding everything else
76syn match puppetComment "\s*#.*$" contains=puppetTodo
77syn region puppetComment start="/\*" end="\*/" contains=puppetTodo extend
78syn 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
83if 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
113endif
114
115let b:current_syntax = "puppet"
116set iskeyword=-,:,@,48-57,_,192-255
117