summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2017-12-07 18:50:33 +0000
committerGitHub <noreply@github.com>2017-12-07 18:50:33 +0000
commitc6fc9cdb7b31823cafc1e86dc4555a595abc9aee (patch)
treec5a2d5dbc6ede832d52221ae4bec5be7c1d6da8a /ale_linters
parent63ecc8341d308c63781e4f7f81347858777d8c89 (diff)
parent85e0bd33141a05216848e525b3e86b6698aa38cd (diff)
downloadale-c6fc9cdb7b31823cafc1e86dc4555a595abc9aee.zip
Merge pull request #1192 from fvictorio/add-solhint-support
Add solhint support
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/solidity/solhint.vim30
1 files changed, 30 insertions, 0 deletions
diff --git a/ale_linters/solidity/solhint.vim b/ale_linters/solidity/solhint.vim
new file mode 100644
index 00000000..519fd49d
--- /dev/null
+++ b/ale_linters/solidity/solhint.vim
@@ -0,0 +1,30 @@
+" 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],
+ \ 'code': l:match[5],
+ \ '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',
+\})