]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/puppet/puppet.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / puppet / puppet.vim
1 " Author: Alexander Olofsson <alexander.olofsson@liu.se>
2
3 call ale#Set('puppet_puppet_executable', 'puppet')
4 call ale#Set('puppet_puppet_options', '')
5
6 function! ale_linters#puppet#puppet#Handle(buffer, lines) abort
7     " Matches patterns like the following:
8     " Error: Could not parse for environment production: Syntax error at ':' at /root/puppetcode/modules/nginx/manifests/init.pp:43:12
9     " Error: Could not parse for environment production: Syntax error at '='; expected '}' at /root/puppetcode/modules/pancakes/manifests/init.pp:5"
10     " Error: Could not parse for environment production: Syntax error at 'parameter1' (file: /tmp/modules/mariadb/manifests/slave.pp, line: 4, column: 5)
11     " Error: Illegal attempt to assign to 'a Name'. Not an assignable reference (file: /tmp/modules/waffles/manifests/syrup.pp, line: 5, column: 11)
12     " Error: Could not parse for environment production: Syntax error at end of input (file: /tmp/modules/bob/manifests/init.pp)
13     let l:pattern = '^Error:\%(.*:\)\? \(.\+\) \((file:\|at\) .\+\.pp\(\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)\|)$\)'
14     let l:output = []
15
16     for l:match in ale#util#GetMatches(a:lines, l:pattern)
17         call add(l:output, {
18         \   'lnum': l:match[5] + 0,
19         \   'col': l:match[7] + 0,
20         \   'text': l:match[1],
21         \})
22     endfor
23
24     return l:output
25 endfunction
26
27 function! ale_linters#puppet#puppet#GetCommand(buffer) abort
28     return '%e parser validate --color=false '
29     \    . ale#Pad(ale#Var(a:buffer, 'puppet_puppet_options'))
30     \    . ' %t'
31 endfunction
32
33 call ale#linter#Define('puppet', {
34 \   'name': 'puppet',
35 \   'executable': {b -> ale#Var(b, 'puppet_puppet_executable')},
36 \   'output_stream': 'stderr',
37 \   'command': function('ale_linters#puppet#puppet#GetCommand'),
38 \   'callback': 'ale_linters#puppet#puppet#Handle',
39 \})