mirror of
https://github.com/amix/vimrc
synced 2025-07-12 06:05:01 +08:00
.
This commit is contained in:
32
sources_non_forked/ale/ale_linters/json/jq.vim
Executable file
32
sources_non_forked/ale/ale_linters/json/jq.vim
Executable file
@ -0,0 +1,32 @@
|
||||
" Author: jD91mZM2 <me@krake.one>
|
||||
|
||||
function! ale_linters#json#jq#GetCommand(buffer) abort
|
||||
let l:executable = ale#fixers#jq#GetExecutable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
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'),
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'command': function('ale_linters#json#jq#GetCommand'),
|
||||
\ 'callback': 'ale_linters#json#jq#Handle',
|
||||
\})
|
0
sources_non_forked/ale/ale_linters/json/jsonlint.vim
Normal file → Executable file
0
sources_non_forked/ale/ale_linters/json/jsonlint.vim
Normal file → Executable file
14
sources_non_forked/ale/ale_linters/json/spectral.vim
Executable file
14
sources_non_forked/ale/ale_linters/json/spectral.vim
Executable file
@ -0,0 +1,14 @@
|
||||
" Author: t2h5 <https://github.com/t2h5>
|
||||
" Description: Integration of Stoplight Spectral CLI with ALE.
|
||||
|
||||
call ale#Set('json_spectral_executable', 'spectral')
|
||||
call ale#Set('json_spectral_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
call ale#linter#Define('json', {
|
||||
\ 'name': 'spectral',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'json_spectral', [
|
||||
\ 'node_modules/.bin/spectral',
|
||||
\ ])},
|
||||
\ 'command': '%e lint --ignore-unknown-format -q -f text %t',
|
||||
\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput'
|
||||
\})
|
Reference in New Issue
Block a user