This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/ale_linters/solidity/solhint.vim

31 lines
1,013 B
VimL
Raw Normal View History

2017-12-04 16:28:52 +00:00
" Author: Franco Victorio - https://github.com/fvictorio
" Description: Report errors in Solidity code with solhint
function! ale_linters#solidity#solhint#Handle(buffer, lines) abort
" Matches patterns like the following:
" /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars)
2017-12-05 19:02:15 +00:00
let l:pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$'
2017-12-04 16:28:52 +00:00
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:isError = l:match[3] is? 'error'
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
2017-12-05 19:02:15 +00:00
\ 'code': l:match[5],
\ 'type': l:isError ? 'E' : 'W',
2017-12-04 16:28:52 +00:00
\})
endfor
return l:output
endfunction
call ale#linter#Define('solidity', {
\ 'name': 'solhint',
\ 'executable': 'solhint',
\ 'command': 'solhint --formatter compact %t',
\ 'callback': 'ale_linters#solidity#solhint#Handle',
\})