mirror of
https://github.com/dense-analysis/ale
synced 2024-12-21 05:43:05 +00:00
e19b8c05cd
Some messages of the crystal compiler are not tied to a file. This causes a 'Key not present in Dictionnary' error (E716). For the record, the json output on ```require "./nonexistent.cr"``` is the following : ```json [ { "file":"/tmp/file.cr", "line":1, "column":1, "size":0, "message":"while requiring \"./nonexistent.cr\"" }, { "message":"can't find file './nonexistent.cr' relative to '/tmp'" } ] ``` The second message does not have line/column attributes.
36 lines
1.0 KiB
VimL
36 lines
1.0 KiB
VimL
" Author: Jordan Andree <https://github.com/jordanandree>, David Alexander <opensource@thelonelyghost.com>
|
|
" Description: This file adds support for checking Crystal with crystal build
|
|
|
|
function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
|
|
let l:output = []
|
|
|
|
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
|
if !has_key(l:error, 'file')
|
|
continue
|
|
endif
|
|
|
|
call add(l:output, {
|
|
\ 'lnum': l:error.line + 0,
|
|
\ 'col': l:error.column + 0,
|
|
\ 'text': l:error.message,
|
|
\})
|
|
endfor
|
|
|
|
return l:output
|
|
endfunction
|
|
|
|
function! ale_linters#crystal#crystal#GetCommand(buffer) abort
|
|
return 'crystal build -f json --no-codegen --no-color -o '
|
|
\ . ale#Escape(g:ale#util#nul_file)
|
|
\ . ' %s'
|
|
endfunction
|
|
|
|
call ale#linter#Define('crystal', {
|
|
\ 'name': 'crystal',
|
|
\ 'executable': 'crystal',
|
|
\ 'output_stream': 'both',
|
|
\ 'lint_file': 1,
|
|
\ 'command': function('ale_linters#crystal#crystal#GetCommand'),
|
|
\ 'callback': 'ale_linters#crystal#crystal#Handle',
|
|
\})
|