]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/crystal/crystal.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / crystal / crystal.vim
1 " Author: Jordan Andree <https://github.com/jordanandree>, David Alexander <opensource@thelonelyghost.com>
2 " Description: This file adds support for checking Crystal with crystal build
3
4 function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
5     let l:output = []
6
7     for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
8         if !has_key(l:error, 'file')
9             continue
10         endif
11
12         call add(l:output, {
13         \   'lnum': l:error.line + 0,
14         \   'col': l:error.column + 0,
15         \   'text': l:error.message,
16         \})
17     endfor
18
19     return l:output
20 endfunction
21
22 function! ale_linters#crystal#crystal#GetCommand(buffer) abort
23     return 'crystal build -f json --no-codegen --no-color -o '
24     \   . ale#Escape(g:ale#util#nul_file)
25     \   . ' %s'
26 endfunction
27
28 call ale#linter#Define('crystal', {
29 \   'name': 'crystal',
30 \   'executable': 'crystal',
31 \   'output_stream': 'both',
32 \   'lint_file': 1,
33 \   'command': function('ale_linters#crystal#crystal#GetCommand'),
34 \   'callback': 'ale_linters#crystal#crystal#Handle',
35 \})