-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathsolc.vim
More file actions
52 lines (44 loc) · 1.76 KB
/
solc.vim
File metadata and controls
52 lines (44 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
" Author: Karl Bartel <[email protected]> - http://karl.berlin/
" Description: Report solc compiler errors in Solidity code
call ale#Set('solidity_solc_executable', 'solc')
call ale#Set('solidity_solc_options', '')
function! ale_linters#solidity#solc#Handle(buffer, lines) abort
" Matches patterns like the following:
" Error: Expected ';' but got '('
" --> /path/to/file/file.sol:1:10:)
let l:buffer_name = bufname(a:buffer)
let l:pattern = '\v(Error|Warning|Note): (.*)$'
let l:line_and_column_pattern = '\v--\> (.*\.sol):(\d+):(\d+):'
let l:output = []
let l:type = "Note"
let l:text = ""
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
let l:match = matchlist(l:line, l:line_and_column_pattern)
if len(l:match) > 0 && l:type != "Note" && l:match[1] == l:buffer_name
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:text,
\ 'type': l:type is? "Error" ? 'E' : 'W',
\})
endif
else
let l:type = l:match[1]
let l:text = l:match[2]
endif
endfor
return l:output
endfunction
function! ale_linters#solidity#solc#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'solidity_solc_executable')
return l:executable . ale#Pad(ale#Var(a:buffer, 'solidity_solc_options')) . ' %s'
endfunction
call ale#linter#Define('solidity', {
\ 'name': 'solc',
\ 'executable': {b -> ale#Var(b, 'solidity_solc_executable')},
\ 'command': function('ale_linters#solidity#solc#GetCommand'),
\ 'callback': 'ale_linters#solidity#solc#Handle',
\ 'output_stream': 'stderr',
\})