]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/groovy/npmgroovylint.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:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / groovy / npmgroovylint.vim
1 " Author: lucas-str <lucas.sturelle@ik.me>
2 " Description: Integration of npm-groovy-lint for Groovy files.
3
4 call ale#Set('groovy_npmgroovylint_executable', 'npm-groovy-lint')
5 call ale#Set('groovy_npmgroovylint_options', '--loglevel warning')
6
7 function! ale_linters#groovy#npmgroovylint#GetCommand(buffer) abort
8     let l:options = ale#Var(a:buffer, 'groovy_npmgroovylint_options')
9
10     return '%e --failon none --output json'
11     \   . (!empty(l:options) ? ' ' . l:options : '')
12     \   . ' %t'
13 endfunction
14
15 function! ale_linters#groovy#npmgroovylint#Handle(buffer, lines) abort
16     let l:output = []
17     let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
18
19     for [l:filename, l:file] in items(get(l:json, 'files', {}))
20         for l:error in get(l:file, 'errors', [])
21             let l:output_line = {
22             \   'filename': l:filename,
23             \   'lnum': l:error.line,
24             \   'text': l:error.msg,
25             \   'type': toupper(l:error.severity[0]),
26             \}
27
28             if has_key(l:error, 'range')
29                 let l:output_line.col = l:error.range.start.character
30                 let l:output_line.end_col = l:error.range.end.character
31                 let l:output_line.end_lnum = l:error.range.end.line
32             endif
33
34             call add(l:output, l:output_line)
35         endfor
36     endfor
37
38     return l:output
39 endfunction
40
41 call ale#linter#Define('groovy', {
42 \   'name': 'npm-groovy-lint',
43 \   'executable': {b -> ale#Var(b, 'groovy_npmgroovylint_executable')},
44 \   'command': function('ale_linters#groovy#npmgroovylint#GetCommand'),
45 \   'callback': 'ale_linters#groovy#npmgroovylint#Handle',
46 \})