2017-06-15 08:30:34 +00:00
|
|
|
" Author: Jordan Andree <https://github.com/jordanandree>, David Alexander <opensource@thelonelyghost.com>
|
2017-04-14 01:19:53 +00:00
|
|
|
" Description: This file adds support for checking Crystal with crystal build
|
|
|
|
|
|
|
|
function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
|
|
|
|
let l:output = []
|
|
|
|
|
2017-07-26 23:45:25 +00:00
|
|
|
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
2019-06-24 04:24:07 +00:00
|
|
|
if !has_key(l:error, 'file')
|
|
|
|
continue
|
|
|
|
endif
|
|
|
|
|
2017-07-26 23:45:25 +00:00
|
|
|
call add(l:output, {
|
|
|
|
\ 'lnum': l:error.line + 0,
|
|
|
|
\ 'col': l:error.column + 0,
|
|
|
|
\ 'text': l:error.message,
|
|
|
|
\})
|
|
|
|
endfor
|
2017-04-14 01:19:53 +00:00
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#crystal#crystal#GetCommand(buffer) abort
|
2017-07-26 23:45:25 +00:00
|
|
|
return 'crystal build -f json --no-codegen --no-color -o '
|
|
|
|
\ . ale#Escape(g:ale#util#nul_file)
|
|
|
|
\ . ' %s'
|
2017-04-14 01:19:53 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('crystal', {
|
|
|
|
\ 'name': 'crystal',
|
|
|
|
\ 'executable': 'crystal',
|
|
|
|
\ 'output_stream': 'both',
|
2017-04-15 14:37:32 +00:00
|
|
|
\ 'lint_file': 1,
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'command': function('ale_linters#crystal#crystal#GetCommand'),
|
2017-04-14 01:19:53 +00:00
|
|
|
\ 'callback': 'ale_linters#crystal#crystal#Handle',
|
|
|
|
\})
|