]> git.r.bdr.sh - rbdr/dotfiles/blob - vim/syntax_checkers/puppet.vim
Add my zshrc
[rbdr/dotfiles] / vim / syntax_checkers / puppet.vim
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 "============================================================================
12 if exists("loaded_puppet_syntax_checker")
13 finish
14 endif
15 let loaded_puppet_syntax_checker = 1
16
17 "bail if the user doesnt have puppet installed
18 if !executable("puppet")
19 finish
20 endif
21
22 function! s:ExtractVersion()
23 let output = system("puppet --version")
24 let output = substitute(output, '\n$', '', '')
25 return split(output, '\.')
26 endfunction
27
28 let s:puppetVersion = s:ExtractVersion()
29
30 function! 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 })
54 endfunction