All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 " Description: Typechecking for nim files
4 let s:end_col_patterns = [
5 \ '\v''([^'']+)'' is declared but not used.*',
6 \ '\videntifier expected, but found ''([^'']+)''',
7 \ '\vimported and not used: ''([^'']+)''.*',
8 \ '\vundeclared identifier: ''([^'']+)''',
9 \ '\v''([^'']+)'' cannot be assigned to',
10 \ '\vredefinition of ''([^'']+)'';',
13 function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
14 let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p:t')
15 let l:pattern = '^\(.\+\.nim\)(\(\d\+\), \(\d\+\)) \(.\+\)'
18 for l:match in ale#util#GetMatches(a:lines, l:pattern)
19 " Only show errors of the current buffer
20 " NOTE: Checking filename only is OK because nim enforces unique
22 let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t')
24 if l:buffer_filename isnot# '' && l:temp_buffer_filename isnot# l:buffer_filename
29 \ 'lnum': l:match[2] + 0,
30 \ 'col': l:match[3] + 0,
35 " Extract error type from message of type 'Error: Some error message'
36 let l:error_match = matchlist(l:item.text, '^\(.\{-}\): \(.\+\)$')
38 if !empty(l:error_match)
39 if l:error_match[1] is# 'Error'
41 let l:item.text = l:error_match[2]
42 elseif l:error_match[1] is# 'Warning'
43 \|| l:error_match[1] is# 'Hint'
44 let l:item.text = l:error_match[2]
48 let l:code_match = matchlist(l:item.text, '\v^(.+) \[([^ \[]+)\]$')
50 if !empty(l:code_match)
51 let l:item.text = l:code_match[1]
52 let l:item.code = l:code_match[2]
55 " Find position end_col.
56 for l:col_match in ale#util#GetMatches(l:item.text, s:end_col_patterns)
57 let l:item.end_col = l:item.col + len(l:col_match[1]) - 1
60 call add(l:output, l:item)
67 function! ale_linters#nim#nimcheck#GetCommand(buffer) abort
68 return 'nim check --verbosity:0 --colors:off --listFullPaths %s'
72 call ale#linter#Define('nim', {
74 \ 'executable': 'nim',
75 \ 'output_stream': 'both',
76 \ 'command': function('ale_linters#nim#nimcheck#GetCommand'),
77 \ 'callback': 'ale_linters#nim#nimcheck#Handle',