summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranco Victorio <victorio.franco@gmail.com>2017-12-04 13:28:52 -0300
committerFranco Victorio <victorio.franco@gmail.com>2017-12-04 14:23:23 -0300
commit0d627d46134a756860beaf825a618313e4133de3 (patch)
tree222c0e86f8868d063e943c32bad6b01bf32d4e07
parent49ccfb1a00e09f6757b6e597883c95a34d612771 (diff)
downloadale-0d627d46134a756860beaf825a618313e4133de3.zip
Add solhint support
-rw-r--r--ale_linters/solidity/solhint.vim29
1 files changed, 29 insertions, 0 deletions
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',
+\})