From d210940339a99902a72fde939ede4f14c24b514c Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 12 Oct 2012 10:54:28 +0100 Subject: [PATCH] puppet: extract the puppet errorformat generation code into a function --- syntax_checkers/puppet.vim | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/syntax_checkers/puppet.vim b/syntax_checkers/puppet.vim index 163d253f..e20cf2db 100644 --- a/syntax_checkers/puppet.vim +++ b/syntax_checkers/puppet.vim @@ -78,25 +78,27 @@ function! s:getPuppetMakeprg() return makeprg endfunction +function! s:getPuppetEfm() + "some versions of puppet (e.g. 2.7.10) output the message below if there + "are any syntax errors + let errorformat = '%-Gerr: Try ''puppet help parser validate'' for usage,' + let errorformat .= 'err: Could not parse for environment %*[a-z]: %m at %f:%l' + + "Puppet 3.0.0 changes this from "err:" to "Error:" + "reset errorformat in that case + if SyntasticIsVersionAtLeast(s:PuppetVersion(), [3,0,0]) + let errorformat = '%-GError: Try ''puppet help parser validate'' for usage,' + let errorformat .= 'Error: Could not parse for environment %*[a-z]: %m at %f:%l' + endif + + return errorformat +endfunction + function! SyntaxCheckers_puppet_GetLocList() let errors = [] if !g:syntastic_puppet_validate_disable - let makeprg = s:getPuppetMakeprg() - - "some versions of puppet (e.g. 2.7.10) output the message below if there - "are any syntax errors - let errorformat = '%-Gerr: Try ''puppet help parser validate'' for usage,' - let errorformat .= 'err: Could not parse for environment %*[a-z]: %m at %f:%l' - - "Puppet 3.0.0 changes this from "err:" to "Error:" - "reset errorformat in that case - if SyntasticIsVersionAtLeast(s:PuppetVersion(), [3,0,0]) - let errorformat = '%-GError: Try ''puppet help parser validate'' for usage,' - let errorformat .= 'Error: Could not parse for environment %*[a-z]: %m at %f:%l' - endif - - let errors = errors + SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + let errors = errors + SyntasticMake({ 'makeprg': s:getPuppetMakeprg(), 'errorformat': s:getPuppetEfm() }) endif if !g:syntastic_puppet_lint_disable