]> git.madduck.net Git - etc/vim.git/blob - ale_linters/cairo/starknet.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 / starknet.vim
1 " Author: 0xHyoga <0xHyoga@gmx.com>
2 " Description: Report starknet-compile errors in cairo code (pre-starknet
3 " 1.0). This is deprecated but kept for backwards compatability.
4
5 call ale#Set('cairo_starknet_executable', 'starknet-compile')
6 call ale#Set('cairo_starknet_options', '')
7
8 function! ale_linters#cairo#starknet#Handle(buffer, lines) abort
9     " Error always on the first line
10     " e.g ex01.cairo:20:6: Could not find module 'contracts.utils.ex00_base'. Searched in the following paths:
11     let l:pattern = '\v\.cairo:(\d+):(\d+):+ (.*)'
12     let l:output = []
13
14     for l:match in ale#util#GetMatches(a:lines, l:pattern)
15         call add(l:output, {
16         \   'lnum': str2nr(l:match[1]),
17         \   'col': str2nr(l:match[2]),
18         \   'type': 'E',
19         \   'text': l:match[3],
20         \})
21     endfor
22
23     return l:output
24 endfunction
25
26 function! ale_linters#cairo#starknet#GetCommand(buffer) abort
27     let l:executable = ale#Var(a:buffer, 'cairo_starknet_executable')
28
29     return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_starknet_options')) . ' %s'
30 endfunction
31
32 call ale#linter#Define('cairo', {
33 \   'name': 'starknet',
34 \   'executable': {b -> ale#Var(b, 'cairo_starknet_executable')},
35 \   'command': function('ale_linters#cairo#starknet#GetCommand'),
36 \   'callback': 'ale_linters#cairo#starknet#Handle',
37 \   'output_stream': 'stderr',
38 \})
39