4b0f3257dd
* Remove 'col' from linters where it is hardcoded to 1 When 'col' is 1, the first column will get highlighted for no reason. It should be 0 (which is the default). In the scalac linter there was also a check about the outcome of `stridx`. It would set l:col to 0 if it was -1, and then it uses `'col': l:col + 1` to convert the outcome of `stridx` to the actual column number. This will make 'col' equals 1 when there is no match. We can remove the check because `-1 + 1 = 0`. * Remove outdated comments about vcol vcol was added as a default, and the loclists that follow these comments do not contain 'vcol' anymore
43 lines
1021 B
VimL
43 lines
1021 B
VimL
" Author: hauleth - https://github.com/hauleth
|
|
|
|
function! ale_linters#elixir#credo#Handle(buffer, lines) abort
|
|
" Matches patterns line the following:
|
|
"
|
|
" lib/filename.ex:19:7: F: Pipe chain should start with a raw value.
|
|
let l:pattern = '\v:(\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:type = l:match[3]
|
|
let l:text = l:match[4]
|
|
|
|
if l:type ==# 'C'
|
|
let l:type = 'E'
|
|
elseif l:type ==# 'R'
|
|
let l:type = 'W'
|
|
endif
|
|
|
|
call add(l:output, {
|
|
\ 'bufnr': a:buffer,
|
|
\ 'lnum': l:match[1] + 0,
|
|
\ 'col': l:match[2] + 0,
|
|
\ 'type': l:type,
|
|
\ 'text': l:text,
|
|
\})
|
|
endfor
|
|
|
|
return l:output
|
|
endfunction
|
|
|
|
call ale#linter#Define('elixir', {
|
|
\ 'name': 'credo',
|
|
\ 'executable': 'mix',
|
|
\ 'command': 'mix credo suggest --format=flycheck --read-from-stdin %s',
|
|
\ 'callback': 'ale_linters#elixir#credo#Handle' })
|