]> git.madduck.net Git - etc/vim.git/blob - ale_linters/cairo/sierra.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 / cairo / sierra.vim
1 " Author: 0xHyoga <0xHyoga@gmx.com>
2 " Description: Report Starknet compile to sierra errors in cairo 1.0 code
3
4 call ale#Set('cairo_sierra_executable', 'starknet-compile')
5 call ale#Set('cairo_sierra_options', '')
6
7 function! ale_linters#cairo#sierra#Handle(buffer, lines) abort
8     " Matches patterns like the following:
9     " Error: Expected ';' but got '('
10     "    --> /path/to/file/file.cairo:1:10:)
11     let l:pattern = '\v(error|warning): (.*)$'
12     let l:line_and_column_pattern = '\v\.cairo:(\d+):(\d+)'
13     let l:output = []
14
15     for l:line in a:lines
16         let l:match = matchlist(l:line, l:pattern)
17
18         if len(l:match) == 0
19             let l:match = matchlist(l:line, l:line_and_column_pattern)
20
21             if len(l:match) > 0
22                 let l:index = len(l:output) - 1
23                 let l:output[l:index]['lnum'] = l:match[1] + 0
24                 let l:output[l:index]['col'] = l:match[2] + 0
25             endif
26         else
27             let l:isError = l:match[1] is? 'Error'
28
29             call add(l:output, {
30             \   'lnum': 0,
31             \   'col': 0,
32             \   'text': l:match[2],
33             \   'type': l:isError ? 'E' : 'W',
34             \})
35         endif
36     endfor
37
38     return l:output
39 endfunction
40
41 function! ale_linters#cairo#sierra#GetCommand(buffer) abort
42     let l:executable = ale#Var(a:buffer, 'cairo_sierra_executable')
43
44     return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_sierra_options')) . ' %s'
45 endfunction
46
47 call ale#linter#Define('cairo', {
48 \   'name': 'sierra',
49 \   'executable': {b -> ale#Var(b, 'cairo_sierra_executable')},
50 \   'command': function('ale_linters#cairo#sierra#GetCommand'),
51 \   'callback': 'ale_linters#cairo#sierra#Handle',
52 \   'output_stream': 'stderr',
53 \})
54