]> git.madduck.net Git - etc/vim.git/blob - ale_linters/bicep/bicep.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:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / ale_linters / bicep / bicep.vim
1 " Author: Carl Smedstad <carl.smedstad at protonmail dot com>
2 " Description: bicep for bicep files
3
4 let g:ale_bicep_bicep_executable =
5 \   get(g:, 'ale_bicep_bicep_executable', 'bicep')
6
7 let g:ale_bicep_bicep_options =
8 \   get(g:, 'ale_bicep_bicep_options', '')
9
10 function! ale_linters#bicep#bicep#Executable(buffer) abort
11     return ale#Var(a:buffer, 'bicep_bicep_executable')
12 endfunction
13
14 function! ale_linters#bicep#bicep#Command(buffer) abort
15     let l:executable = ale_linters#bicep#bicep#Executable(a:buffer)
16     let l:options = ale#Var(a:buffer, 'bicep_bicep_options')
17
18     if has('win32')
19         let l:nullfile = 'NUL'
20     else
21         let l:nullfile = '/dev/null'
22     endif
23
24     return ale#Escape(l:executable)
25     \   . ' build --outfile '
26     \   . l:nullfile
27     \   . ' '
28     \   . l:options
29     \   . ' %s'
30 endfunction
31
32 function! ale_linters#bicep#bicep#Handle(buffer, lines) abort
33     let l:pattern = '\v^(.*)\((\d+),(\d+)\)\s:\s([a-zA-Z]*)\s([-a-zA-Z0-9]*):\s(.*)'
34     let l:output = []
35
36     for l:match in ale#util#GetMatches(a:lines, l:pattern)
37         if l:match[4] is# 'Error'
38             let l:type = 'E'
39         elseif l:match[4] is# 'Warning'
40             let l:type = 'W'
41         else
42             let l:type = 'I'
43         endif
44
45         call add(l:output, {
46         \   'filename': l:match[1],
47         \   'lnum': l:match[2] + 0,
48         \   'col': l:match[3] + 0,
49         \   'type': l:type,
50         \   'code': l:match[5],
51         \   'text': l:match[6],
52         \})
53     endfor
54
55     return l:output
56 endfunction
57
58 call ale#linter#Define('bicep', {
59 \   'name': 'bicep',
60 \   'executable': function('ale_linters#bicep#bicep#Executable'),
61 \   'command': function('ale_linters#bicep#bicep#Command'),
62 \   'callback': 'ale_linters#bicep#bicep#Handle',
63 \   'output_stream': 'both',
64 \   'lint_file': 1,
65 \})