From 0d627d46134a756860beaf825a618313e4133de3 Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Mon, 4 Dec 2017 13:28:52 -0300 Subject: [PATCH] Add solhint support --- ale_linters/solidity/solhint.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ale_linters/solidity/solhint.vim diff --git a/ale_linters/solidity/solhint.vim b/ale_linters/solidity/solhint.vim new file mode 100644 index 00000000..cab2c18a --- /dev/null +++ b/ale_linters/solidity/solhint.vim @@ -0,0 +1,29 @@ +" 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) + + let l:pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*)$' + 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], + \ 'type': l:isError ? 'E' : 'W' + \}) + 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', +\})