This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/ale_linters/json/jq.vim

33 lines
973 B
VimL
Raw Permalink Normal View History

2021-01-31 12:01:03 +00:00
" Author: jD91mZM2 <me@krake.one>
function! ale_linters#json#jq#GetCommand(buffer) abort
let l:executable = ale#fixers#jq#GetExecutable(a:buffer)
2021-01-31 12:01:03 +00:00
2021-02-02 12:01:03 +00:00
return ale#Escape(l:executable)
2021-01-31 12:01:03 +00:00
endfunction
function! ale_linters#json#jq#Handle(buffer, lines) abort
" Matches patterns like the following:
" parse error: Expected another key-value pair at line 4, column 3
let l:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'text': l:match[1],
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\})
endfor
return l:output
endfunction
call ale#linter#Define('json', {
\ 'name': 'jq',
\ 'executable': function('ale#fixers#jq#GetExecutable'),
2021-01-31 12:01:03 +00:00
\ 'output_stream': 'stderr',
\ 'command': function('ale_linters#json#jq#GetCommand'),
\ 'callback': 'ale_linters#json#jq#Handle',
\})