File: crystal.vim

package info (click to toggle)
vim-ale 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,764 kB
  • sloc: sh: 499; python: 311; perl: 31; makefile: 4; xml: 4; javascript: 1
file content (35 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
" 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',
\})