]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/clojure/clj_kondo.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 / clojure / clj_kondo.vim
1 " Author: Masashi Iizuka <liquidz.uo@gmail.com>
2 " Description: linter for clojure using clj-kondo https://github.com/borkdude/clj-kondo
3
4 call ale#Set('clojure_clj_kondo_options', '--cache')
5
6 function! ale_linters#clojure#clj_kondo#GetCommand(buffer) abort
7     let l:options = ale#Var(a:buffer, 'clojure_clj_kondo_options')
8
9     let l:command = 'clj-kondo'
10     \   . ale#Pad(l:options)
11     \   . ' --lint -'
12     \   . ' --filename %s'
13
14     return l:command
15 endfunction
16
17 function! ale_linters#clojure#clj_kondo#HandleCljKondoFormat(buffer, lines) abort
18     " output format
19     " <filename>:<line>:<column>: <issue type>: <message>
20     let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+)?:(\d+)?:? ((Exception|error|warning): ?(.+))$'
21     let l:output = []
22
23     for l:match in ale#util#GetMatches(a:lines, l:pattern)
24         let l:type = 'E'
25
26         if l:match[4] is? 'warning'
27             let l:type = 'W'
28         endif
29
30         call add(l:output, {
31         \   'lnum': l:match[1] + 0,
32         \   'col': l:match[2] + 0,
33         \   'text': l:match[3],
34         \   'type': l:type,
35         \})
36     endfor
37
38     return l:output
39 endfunction
40
41 call ale#linter#Define('clojure', {
42 \   'name': 'clj-kondo',
43 \   'output_stream': 'stdout',
44 \   'executable': 'clj-kondo',
45 \   'command': function('ale_linters#clojure#clj_kondo#GetCommand'),
46 \   'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat',
47 \})