|
1 | 1 | " Author: jD91mZM2 <[email protected]> |
| 2 | +call ale#Set('json_jq_executable', 'jq') |
| 3 | +call ale#Set('json_jq_options', '') |
| 4 | +call ale#Set('json_jq_filters', '.') |
2 | 5 |
|
3 | | -function! ale_linters#json#jq#GetCommand(buffer) abort |
4 | | - let l:executable = ale#fixers#jq#GetExecutable(a:buffer) |
5 | | - |
6 | | - return ale#Escape(l:executable) |
7 | | -endfunction |
| 6 | +" Matches patterns like the following: |
| 7 | +" parse error: Expected another key-value pair at line 4, column 3 |
| 8 | +let s:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' |
8 | 9 |
|
9 | 10 | function! ale_linters#json#jq#Handle(buffer, lines) abort |
10 | | - " Matches patterns like the following: |
11 | | - " parse error: Expected another key-value pair at line 4, column 3 |
12 | | - let l:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' |
13 | | - let l:output = [] |
14 | | - |
15 | | - for l:match in ale#util#GetMatches(a:lines, l:pattern) |
16 | | - call add(l:output, { |
17 | | - \ 'text': l:match[1], |
18 | | - \ 'lnum': l:match[2] + 0, |
19 | | - \ 'col': l:match[3] + 0, |
20 | | - \}) |
21 | | - endfor |
22 | | - |
23 | | - return l:output |
| 11 | + return ale#util#MapMatches(a:lines, s:pattern, {match -> { |
| 12 | + \ 'text': match[1], |
| 13 | + \ 'lnum': match[2] + 0, |
| 14 | + \ 'col': match[3] + 0, |
| 15 | + \}}) |
24 | 16 | endfunction |
25 | 17 |
|
26 | 18 | call ale#linter#Define('json', { |
27 | 19 | \ 'name': 'jq', |
28 | | -\ 'executable': function('ale#fixers#jq#GetExecutable'), |
| 20 | +\ 'executable': {b -> ale#Var(b, 'json_jq_executable')}, |
29 | 21 | \ 'output_stream': 'stderr', |
30 | | -\ 'command': function('ale_linters#json#jq#GetCommand'), |
| 22 | +\ 'command': '%e', |
31 | 23 | \ 'callback': 'ale_linters#json#jq#Handle', |
32 | 24 | \}) |
0 commit comments