From eba9ab332d205357d86a777d6bf6bf30a9c6293f Mon Sep 17 00:00:00 2001 From: Ruslan Kiianchuk Date: Wed, 4 Mar 2015 17:48:18 -0800 Subject: [PATCH 1/2] Fix syntax highlighting of class definition arguments The `puppetDefArguments` region incorrectly highlights arguments if they contain functions due to braces in those functions that make the region to end at the first such argument, not at the end of definitions. See the example below: ``` class profile::dao::aio ( $yum_baseurl = hiera('yum::baseurl'), $yum_baseurl_deps = hiera('yum::baseurl_deps'), # Comment here $debug = hiera('debug', false), ) { ... } ``` Suggested changes handle situations with functions in class definition better and also highlight inline comments. --- syntax/puppet.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syntax/puppet.vim b/syntax/puppet.vim index 9605210..41a4bba 100644 --- a/syntax/puppet.vim +++ b/syntax/puppet.vim @@ -19,7 +19,8 @@ endif " match class/definition/node declarations syn region puppetDefine start="^\s*\(class\|define\|node\)\s" end="{" contains=puppetDefType,puppetDefName,puppetDefArguments,puppetNodeRe syn keyword puppetDefType class define node inherits contained -syn region puppetDefArguments start="(" end=")" contained contains=puppetArgument,puppetString +syn region puppetDefArguments start="(" end=")" contained contains=puppetDefValues,puppetArgument,puppetDefName,puppetComment,puppetMultilineComment +syn region puppetDefValues start="(" end=")" contained contains=puppetArgument,puppetString,puppetDefName,puppetSpecial syn match puppetArgument "\w\+" contained syn match puppetArgument "\$\w\+" contained syn match puppetArgument "'[^']+'" contained From 7f9c5317b842ace5ce39b54fa63919488a490114 Mon Sep 17 00:00:00 2001 From: Ruslan Kiianchuk Date: Thu, 5 Mar 2015 15:25:35 -0800 Subject: [PATCH 2/2] Fix pattern matching Previous version had a bug and affected further class definition in `{ ... }` This one seems ok, but still ugly. If you know better way to overcome functions inside the class arguments declaration, please let me know. --- syntax/puppet.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/puppet.vim b/syntax/puppet.vim index 41a4bba..f5a69d1 100644 --- a/syntax/puppet.vim +++ b/syntax/puppet.vim @@ -19,8 +19,8 @@ endif " match class/definition/node declarations syn region puppetDefine start="^\s*\(class\|define\|node\)\s" end="{" contains=puppetDefType,puppetDefName,puppetDefArguments,puppetNodeRe syn keyword puppetDefType class define node inherits contained -syn region puppetDefArguments start="(" end=")" contained contains=puppetDefValues,puppetArgument,puppetDefName,puppetComment,puppetMultilineComment -syn region puppetDefValues start="(" end=")" contained contains=puppetArgument,puppetString,puppetDefName,puppetSpecial +syn region puppetDefArguments start="(" end=")" contained contains=puppetArgument,puppetString,puppetComment,puppetArgFunction +syn match puppetArgFunction "(.\{-})" contained contains=puppetArgument,puppetString,puppetParamSpecial syn match puppetArgument "\w\+" contained syn match puppetArgument "\$\w\+" contained syn match puppetArgument "'[^']+'" contained