diff options
author | baabelfish <baabelfish@gmail.com> | 2017-03-18 18:33:26 +0200 |
---|---|---|
committer | baabelfish <baabelfish@gmail.com> | 2017-03-18 19:45:37 +0200 |
commit | 297bc8553c33211e706e6b82fe819e69710d7d8b (patch) | |
tree | 56a4c672cd3f8c9feae04a788e3cb9f079371f6e /ale_linters/nim/nimcheck.vim | |
parent | e7d32fe37677636a0be087163c1efa7d0ba10d47 (diff) | |
download | ale-297bc8553c33211e706e6b82fe819e69710d7d8b.zip |
Add support for nim check
Diffstat (limited to 'ale_linters/nim/nimcheck.vim')
-rw-r--r-- | ale_linters/nim/nimcheck.vim | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/ale_linters/nim/nimcheck.vim b/ale_linters/nim/nimcheck.vim new file mode 100644 index 00000000..d3e6853d --- /dev/null +++ b/ale_linters/nim/nimcheck.vim @@ -0,0 +1,55 @@ +" Author: Baabelfish +" Description: Typechecking for nim files + + +function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort + let l:pattern = '^\(.\+\.nim\)(\(\d\+\), \(\d\+\)) \(.\+\)' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:buffer = l:match[1] + 0 + let l:line = l:match[2] + 0 + let l:column = l:match[3] + 0 + let l:text = l:match[4] + let l:type = 'W' + + let l:textmatch = matchlist(l:match[4], '\(.*\):') + + if len(l:textmatch) > 0 + let l:errortype = l:textmatch[1] + if l:errortype ==# 'Error' + let l:type = 'E' + endif + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:line, + \ 'col': l:column, + \ 'text': l:text, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + + +function! ale_linters#nim#nimcheck#GetCommand(buffer) + return 'nim check --path:' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h')) . ' --verbosity:0 --colors:off --listFullPaths %t' +endfunction + + +call ale#linter#Define('nim', { +\ 'name': 'nimcheck', +\ 'executable': 'nim', +\ 'output_stream': 'both', +\ 'command_callback': 'ale_linters#nim#nimcheck#GetCommand', +\ 'callback': 'ale_linters#nim#nimcheck#Handle' +\}) |