mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
add crystal lint
- invokes via `crystal build` command without codegen - adds vader tests
This commit is contained in:
40
ale_linters/crystal/crystal.vim
Normal file
40
ale_linters/crystal/crystal.vim
Normal file
@@ -0,0 +1,40 @@
|
||||
" Author: Jordan Andree <https://github.com/jordanandree>
|
||||
" Description: This file adds support for checking Crystal with crystal build
|
||||
|
||||
function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
|
||||
let l:output = []
|
||||
|
||||
let l:lines = join(a:lines, '')
|
||||
|
||||
if !empty(l:lines)
|
||||
let l:errors = json_decode(l:lines)
|
||||
|
||||
for l:error in l:errors
|
||||
call add(l:output, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:error.line + 0,
|
||||
\ 'col': l:error.column + 0,
|
||||
\ 'text': l:error.message,
|
||||
\ 'type': 'E',
|
||||
\})
|
||||
endfor
|
||||
endif
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#crystal#crystal#GetCommand(buffer) abort
|
||||
let l:crystal_cmd = 'crystal build -f json --no-codegen -o '
|
||||
let l:crystal_cmd .= shellescape(g:ale#util#nul_file)
|
||||
let l:crystal_cmd .= ' %t'
|
||||
|
||||
return l:crystal_cmd
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('crystal', {
|
||||
\ 'name': 'crystal',
|
||||
\ 'executable': 'crystal',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'command_callback': 'ale_linters#crystal#crystal#GetCommand',
|
||||
\ 'callback': 'ale_linters#crystal#crystal#Handle',
|
||||
\})
|
||||
Reference in New Issue
Block a user