summaryrefslogtreecommitdiff
path: root/ale_linters/nim/nimcheck.vim
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-19 00:38:00 +0000
committerw0rp <devw0rp@gmail.com>2017-11-19 00:38:00 +0000
commitc012563984f0470a7c637b3b55cebea28b7a50b0 (patch)
treefdd4fde368d261fa5c796cb7f2aee0ffa47ccca4 /ale_linters/nim/nimcheck.vim
parent3c8f3221df1afe40ab8476c6b71a50a6f21df9c7 (diff)
downloadale-c012563984f0470a7c637b3b55cebea28b7a50b0.zip
#852 - Capture error codes for nimcheck
Diffstat (limited to 'ale_linters/nim/nimcheck.vim')
-rw-r--r--ale_linters/nim/nimcheck.vim39
1 files changed, 23 insertions, 16 deletions
diff --git a/ale_linters/nim/nimcheck.vim b/ale_linters/nim/nimcheck.vim
index cdd8c564..bff45f7d 100644
--- a/ale_linters/nim/nimcheck.vim
+++ b/ale_linters/nim/nimcheck.vim
@@ -10,33 +10,40 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
" Only show errors of the current buffer
" NOTE: Checking filename only is OK because nim enforces unique
" module names.
-
let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t')
+
if l:buffer_filename isnot# '' && l:temp_buffer_filename isnot# l:buffer_filename
continue
endif
- 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:item = {
+ \ 'lnum': l:match[2] + 0,
+ \ 'col': l:match[3] + 0,
+ \ 'text': l:match[4],
+ \ 'type': 'W',
+ \}
" Extract error type from message of type 'Error: Some error message'
- let l:textmatch = matchlist(l:match[4], '^\(.\{-}\): .\+$')
+ let l:error_match = matchlist(l:item.text, '^\(.\{-}\): \(.\+\)$')
- if len(l:textmatch) > 0
- let l:errortype = l:textmatch[1]
- if l:errortype is# 'Error'
- let l:type = 'E'
+ if !empty(l:error_match)
+ if l:error_match[1] is# 'Error'
+ let l:item.type = 'E'
+ let l:item.text = l:error_match[2]
+ elseif l:error_match[1] is# 'Warning'
+ \|| l:error_match[1] is# 'Hint'
+ let l:item.text = l:error_match[2]
endif
endif
- call add(l:output, {
- \ 'lnum': l:line,
- \ 'col': l:column,
- \ 'text': l:text,
- \ 'type': l:type,
- \})
+ let l:code_match = matchlist(l:item.text, '\v^(.+) \[([^ \[]+)\]$')
+
+ if !empty(l:code_match)
+ let l:item.text = l:code_match[1]
+ let l:item.code = l:code_match[2]
+ endif
+
+ call add(l:output, l:item)
endfor
return l:output