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.
1 " Author: Harrison Bachrach - https://github.com/HarrisonB
2 " Description: Ameba, a linter for crystal files
4 call ale#Set('crystal_ameba_executable', 'bin/ameba')
6 function! ale_linters#crystal#ameba#GetCommand(buffer) abort
7 let l:executable = ale#Var(a:buffer, 'crystal_ameba_executable')
9 return ale#Escape(l:executable)
11 \ . ale#Escape(expand('#' . a:buffer . ':p'))
14 " Handle output from ameba
15 function! ale_linters#crystal#ameba#HandleAmebaOutput(buffer, lines) abort
20 let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], {})
22 if !has_key(l:errors, 'summary')
23 \|| l:errors['summary']['issues_count'] == 0
24 \|| empty(l:errors['sources'])
30 for l:error in l:errors['sources'][0]['issues']
31 let l:start_col = str2nr(l:error['location']['column'])
32 let l:end_col = str2nr(l:error['end_location']['column'])
35 let l:end_col = l:start_col + 1
39 \ 'lnum': str2nr(l:error['location']['line']),
41 \ 'end_col': l:end_col,
42 \ 'code': l:error['rule_name'],
43 \ 'text': l:error['message'],
51 call ale#linter#Define('crystal', {
53 \ 'executable': {b -> ale#Var(b, 'crystal_ameba_executable')},
54 \ 'command': function('ale_linters#crystal#ameba#GetCommand'),
55 \ 'callback': 'ale_linters#crystal#ameba#HandleAmebaOutput',