summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorMarc Fournier <marc.fournier@camptocamp.com>2009-06-08 22:54:03 +0200
committerMarc Fournier <marc.fournier@camptocamp.com>2009-06-10 12:09:43 +0200
commit446557fbdf2051d59554f2d2cf6aa18c1f6eec83 (patch)
tree116908a730a1d48443ef155a44b75b0f0d28ed9c /ext
parent91526785f5c71d0750c48c0876c8148894bb9be6 (diff)
downloadpuppet-446557fbdf2051d59554f2d2cf6aa18c1f6eec83.tar.gz
puppet-446557fbdf2051d59554f2d2cf6aa18c1f6eec83.tar.xz
puppet-446557fbdf2051d59554f2d2cf6aa18c1f6eec83.zip
vim: several improvements + cleanup
* added highlighting for different type of keywords: * if/else * undef * puppet function names * parameters passed to "ensure" * unquoted digits * fixed regexps to match resources containing "::", "-" and "_" * handled escaped variables (variable which don't belong to puppet) * removed unused definitions and added comments
Diffstat (limited to 'ext')
-rw-r--r--ext/vim/syntax/puppet.vim58
1 files changed, 38 insertions, 20 deletions
diff --git a/ext/vim/syntax/puppet.vim b/ext/vim/syntax/puppet.vim
index a60a77bfd..123771372 100644
--- a/ext/vim/syntax/puppet.vim
+++ b/ext/vim/syntax/puppet.vim
@@ -16,9 +16,9 @@ elseif exists("b:current_syntax")
finish
endif
+" match class/definition/node declarations
syn region puppetDefine start="^\s*\(class\|define\|node\)" end="{" contains=puppetDefType,puppetDefName,puppetDefArguments
syn keyword puppetDefType class define node inherits contained
-syn keyword puppetInherits inherits contained
syn region puppetDefArguments start="(" end=")" contains=puppetArgument
syn match puppetArgument "\w\+" contained
syn match puppetArgument "\$\w\+" contained
@@ -26,32 +26,51 @@ syn match puppetArgument "'[^']+'" contained
syn match puppetArgument '"[^"]+"' contained
syn match puppetDefName "\w\+" contained
-syn match puppetInstance "\w\+\s*{" contains=puppetTypeBrace,puppetTypeName,puppetTypeDefault
-syn match puppetTypeBrace "{" contained
+" match 'foo' in 'class foo { ...'
+" match 'foo::bar' in 'class foo::bar { ...'
+" match 'Foo::Bar' in 'Foo::Bar["..."]
+"FIXME: "Foo-bar" doesn't get highlighted as expected, although "foo-bar" does.
+syn match puppetInstance "[A-Za-z0-9_-]\+\(::[A-Za-z0-9_-]\+\)*\s*{" contains=puppetTypeName,puppetTypeDefault
+syn match puppetInstance "[A-Z][a-z_-]\+\(::[A-Z][a-z_-]\+\)*\s*[[{]" contains=puppetTypeName,puppetTypeDefault
syn match puppetTypeName "[a-z]\w*" contained
syn match puppetTypeDefault "[A-Z]\w*" contained
-syn match puppetParam "\w\+\s*[=+]>" contains=puppetTypeRArrow,puppetParamName
-syn match puppetParamRArrow "[=+]>" contained
+" match 'foo' in 'foo => "bar"'
+syn match puppetParam "\w\+\s*[=+]>" contains=puppetParamName
syn match puppetParamName "\w\+" contained
+
+" match 'present' in 'ensure => present'
+" match '2755' in 'mode => 2755'
+" don't match 'bar' in 'foo => bar'
+syn match puppetParam "\w\+\s*[=+]>\s*[a-z0-9]\+" contains=puppetParamString,puppetParamName
+syn match puppetParamString "[=+]>\s*\w\+" contains=puppetParamKeyword,puppetParamSpecial,puppetParamDigits contained
+syn keyword puppetParamKeyword present absent purged latest installed running stopped mounted unmounted role configured file directory link contained
+syn keyword puppetParamSpecial true false undef contained
+syn match puppetParamDigits "[0-9]\+"
+
+" match 'template' in 'content => template("...")'
+syn match puppetParam "\w\+\s*[=+]>\s*\w\+\s*(" contains=puppetFunction,puppetParamName
+syn keyword puppetFunction debug info notice warning err alert emerg crit
+syn keyword puppetFunction sprintf template fail tagged include generate search file tag versioncmp fqdn_rand realize split defined regsubst sha1 inline_template
+
syn match puppetVariable "$\w\+"
syn match puppetVariable "${\w\+}"
-syn match puppetParen "("
-syn match puppetParen ")"
-syn match puppetBrace "{"
-syn match puppetBrace "}"
+" match anything between simple/double quotes.
+" don't match variables if preceded by a backslash.
syn region puppetString start=+'+ skip=+\\\\\|\\'+ end=+'+
-syn region puppetString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=puppetVariable
+syn region puppetString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=puppetVariable,puppetNotVariable
+syn match puppetNotVariable "\\$\w\+" contained
+syn match puppetNotVariable "\\${\w\+}" contained
-syn keyword puppetBoolean true false
syn keyword puppetKeyword import inherits include
-syn keyword puppetControl case default
+syn keyword puppetControl case default if else
+syn keyword puppetSpecial true false undef
" comments last overriding everything else
syn match puppetComment "\s*#.*$" contains=puppetTodo
syn region puppetComment start="/\*" end="\*/" contains=puppetTodo extend
-syn keyword puppetTodo TODO NOTE FIXME XXX contained
+syn keyword puppetTodo TODO NOTE FIXME XXX BUG HACK contained
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
@@ -65,18 +84,16 @@ if version >= 508 || !exists("did_puppet_syn_inits")
endif
HiLink puppetVariable Identifier
- HiLink puppetBoolean Boolean
HiLink puppetType Identifier
- HiLink puppetDefault Identifier
HiLink puppetKeyword Define
- HiLink puppetTypeDefs Define
HiLink puppetComment Comment
HiLink puppetString String
+ HiLink puppetParamKeyword String
+ HiLink puppetParamDigits String
+ HiLink puppetNotVariable String
+ HiLink puppetParamSpecial Special
+ HiLink puppetSpecial Special
HiLink puppetTodo Todo
-" HiLink puppetBrace Delimiter
-" HiLink puppetTypeBrace Delimiter
-" HiLink puppetParen Delimiter
- HiLink puppetDelimiter Delimiter
HiLink puppetControl Statement
HiLink puppetDefType Define
HiLink puppetDefName Type
@@ -84,6 +101,7 @@ if version >= 508 || !exists("did_puppet_syn_inits")
HiLink puppetTypeDefault Type
HiLink puppetParamName Identifier
HiLink puppetArgument Identifier
+ HiLink puppetFunction Function
delcommand HiLink
endif