mirror of
https://github.com/amix/vimrc
synced 2025-06-17 02:15:01 +08:00
Updated plugins
This commit is contained in:
@ -11,7 +11,7 @@ function! ale_linters#sql#sqlfluff#Executable(buffer) abort
|
||||
return ale#Var(a:buffer, 'sql_sqlfluff_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sql#sqlfluff#Command(buffer) abort
|
||||
function! ale_linters#sql#sqlfluff#Command(buffer, version) abort
|
||||
let l:executable = ale_linters#sql#sqlfluff#Executable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'sql_sqlfluff_options')
|
||||
|
||||
@ -35,7 +35,7 @@ function! ale_linters#sql#sqlfluff#Command(buffer) abort
|
||||
return l:cmd
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sql#sqlfluff#Handle(buffer, lines) abort
|
||||
function! ale_linters#sql#sqlfluff#Handle(buffer, version, lines) abort
|
||||
let l:output = []
|
||||
let l:json_lines = ale#util#FuzzyJSONDecode(a:lines, [])
|
||||
|
||||
@ -50,16 +50,31 @@ function! ale_linters#sql#sqlfluff#Handle(buffer, lines) abort
|
||||
return l:output
|
||||
endif
|
||||
|
||||
for l:violation in get(l:json, 'violations', [])
|
||||
call add(l:output, {
|
||||
\ 'filename': l:json.filepath,
|
||||
\ 'lnum': l:violation.line_no,
|
||||
\ 'col': l:violation.line_pos,
|
||||
\ 'text': l:violation.description,
|
||||
\ 'code': l:violation.code,
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
if ale#semver#GTE(a:version, [3, 0, 0])
|
||||
for l:violation in get(l:json, 'violations', [])
|
||||
call add(l:output, {
|
||||
\ 'filename': l:json.filepath,
|
||||
\ 'lnum': l:violation.start_line_no,
|
||||
\ 'end_lnum': l:violation.end_line_no,
|
||||
\ 'col': l:violation.start_line_pos,
|
||||
\ 'end_col': l:violation.end_line_pos,
|
||||
\ 'text': l:violation.description,
|
||||
\ 'code': l:violation.code,
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
else
|
||||
for l:violation in get(l:json, 'violations', [])
|
||||
call add(l:output, {
|
||||
\ 'filename': l:json.filepath,
|
||||
\ 'lnum': l:violation.line_no,
|
||||
\ 'col': l:violation.line_pos,
|
||||
\ 'text': l:violation.description,
|
||||
\ 'code': l:violation.code,
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
endif
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
@ -67,6 +82,19 @@ endfunction
|
||||
call ale#linter#Define('sql', {
|
||||
\ 'name': 'sqlfluff',
|
||||
\ 'executable': function('ale_linters#sql#sqlfluff#Executable'),
|
||||
\ 'command': function('ale_linters#sql#sqlfluff#Command'),
|
||||
\ 'callback': 'ale_linters#sql#sqlfluff#Handle',
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale_linters#sql#sqlfluff#Executable(buffer),
|
||||
\ '%e --version',
|
||||
\ function('ale_linters#sql#sqlfluff#Command'),
|
||||
\ )},
|
||||
\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale_linters#sql#sqlfluff#Executable(buffer),
|
||||
\ '%e --version',
|
||||
\ {buffer, version -> ale_linters#sql#sqlfluff#Handle(
|
||||
\ buffer,
|
||||
\ l:version,
|
||||
\ lines)},
|
||||
\ )},
|
||||
\})
|
||||
|
Reference in New Issue
Block a user