]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - vim/syntax_checkers/puppet.vim
Update the stuff
[rbdr/dotfiles] / vim / syntax_checkers / puppet.vim
... / ...
CommitLineData
1"============================================================================
2"File: puppet.vim
3"Description: Syntax checking plugin for syntastic.vim
4"Maintainer: Eivind Uggedal <eivind at uggedal dot com>
5"License: This program is free software. It comes without any warranty,
6" to the extent permitted by applicable law. You can redistribute
7" it and/or modify it under the terms of the Do What The Fuck You
8" Want To Public License, Version 2, as published by Sam Hocevar.
9" See http://sam.zoy.org/wtfpl/COPYING for more details.
10"
11"============================================================================
12if exists("loaded_puppet_syntax_checker")
13 finish
14endif
15let loaded_puppet_syntax_checker = 1
16
17"bail if the user doesnt have puppet installed
18if !executable("puppet")
19 finish
20endif
21
22function! s:ExtractVersion()
23 let output = system("puppet --version")
24 let output = substitute(output, '\n$', '', '')
25 return split(output, '\.')
26endfunction
27
28let s:puppetVersion = s:ExtractVersion()
29
30function! SyntaxCheckers_puppet_GetLocList()
31 "If puppet is >= version 2.7 then use the new executable
32 if s:puppetVersion[0] >= '2' && s:puppetVersion[1] >= '7'
33 let makeprg = 'puppet parser validate ' .
34 \ shellescape(expand('%')) .
35 \ ' --color=false' .
36 \ ' --storeconfigs'
37
38 "add --ignoreimport for versions < 2.7.10
39 if s:puppetVersion[2] < '10'
40 let makeprg .= ' --ignoreimport'
41 endif
42
43 else
44 let makeprg = 'puppet --color=false --parseonly --ignoreimport '.shellescape(expand('%'))
45 endif
46
47 "some versions of puppet (e.g. 2.7.10) output the message below if there
48 "are any syntax errors
49 let errorformat = '%-Gerr: Try ''puppet help parser validate'' for usage,'
50
51 let errorformat .= 'err: Could not parse for environment %*[a-z]: %m at %f:%l'
52
53 return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
54endfunction