mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -1,18 +1,51 @@
|
||||
" Author: Alistair Bill <@alibabzo>
|
||||
" Author: Maximilian Bosch <maximilian@mbosch.me>
|
||||
" Description: nix-instantiate linter for nix files
|
||||
|
||||
function! ale_linters#nix#nix#Command(buffer, output, meta) abort
|
||||
let l:version = a:output[0][22:]
|
||||
|
||||
if l:version =~# '^\(2.4\|3\).*'
|
||||
return 'nix-instantiate --log-format internal-json --parse -'
|
||||
else
|
||||
return 'nix-instantiate --parse -'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale_linters#nix#nix#Handle(buffer, lines) abort
|
||||
let l:pattern = '^\(.\+\): \(.\+\), at .*:\(\d\+\):\(\d\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[3] + 0,
|
||||
\ 'col': l:match[4] + 0,
|
||||
\ 'text': l:match[1] . ': ' . l:match[2],
|
||||
\ 'type': l:match[1] =~# '^error' ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
if empty(a:lines)
|
||||
return l:output
|
||||
endif
|
||||
|
||||
if a:lines[0] =~# '^@nix .*'
|
||||
for l:line in a:lines
|
||||
if l:line =~# '^@nix .*'
|
||||
let l:result = json_decode(strpart(l:line, 4))
|
||||
|
||||
if has_key(l:result, 'column')
|
||||
call add(l:output, {
|
||||
\ 'type': 'E',
|
||||
\ 'lnum': l:result.line,
|
||||
\ 'col': l:result.column,
|
||||
\ 'text': l:result.raw_msg
|
||||
\})
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
let l:pattern = '^\(.\+\): \(.\+\) at .*:\(\d\+\):\(\d\+\)$'
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[3] + 0,
|
||||
\ 'col': l:match[4] + 0,
|
||||
\ 'text': l:match[1] . ': ' . substitute(l:match[2], ',$', '', ''),
|
||||
\ 'type': l:match[1] =~# '^error' ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
endif
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
@ -21,6 +54,10 @@ call ale#linter#Define('nix', {
|
||||
\ 'name': 'nix',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'nix-instantiate',
|
||||
\ 'command': 'nix-instantiate --parse -',
|
||||
\ 'command': {buffer -> ale#command#Run(
|
||||
\ buffer,
|
||||
\ 'nix-instantiate --version',
|
||||
\ function('ale_linters#nix#nix#Command')
|
||||
\ )},
|
||||
\ 'callback': 'ale_linters#nix#nix#Handle',
|
||||
\})
|
||||
|
16
sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim
Normal file
16
sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim
Normal file
@ -0,0 +1,16 @@
|
||||
" Author: jD91mZM2 <me@krake.one>
|
||||
" Description: rnix-lsp language client
|
||||
|
||||
function! ale_linters#nix#rnix_lsp#GetProjectRoot(buffer) abort
|
||||
" rnix-lsp does not yet use the project root, so getting it right is not
|
||||
" important
|
||||
return fnamemodify(a:buffer, ':h')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('nix', {
|
||||
\ 'name': 'rnix_lsp',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': 'rnix-lsp',
|
||||
\ 'command': '%e',
|
||||
\ 'project_root': function('ale_linters#nix#rnix_lsp#GetProjectRoot'),
|
||||
\})
|
Reference in New Issue
Block a user