mirror of
https://github.com/amix/vimrc
synced 2025-07-14 15:34:59 +08:00
Updated plugins
This commit is contained in:
@ -26,9 +26,27 @@ function! s:AbbreviateMessage(text) abort
|
||||
endfunction
|
||||
|
||||
function! s:GetCommand(buffer) abort
|
||||
let l:file = ale#Escape(expand('#' . a:buffer . ':.'))
|
||||
let l:cwd = s:GetCwd(a:buffer)
|
||||
|
||||
return '%e rock --output-format=parsable ' . l:file
|
||||
let l:file = !empty(l:cwd)
|
||||
\ ? expand('#' . a:buffer . ':p')[len(l:cwd) + 1:]
|
||||
\ : expand('#' . a:buffer . ':.')
|
||||
|
||||
return '%e rock --output-format=parsable ' . ale#Escape(l:file)
|
||||
endfunction
|
||||
|
||||
function! s:GetCwd(buffer) abort
|
||||
let l:markers = ['elvis.config', 'rebar.lock', 'erlang.mk']
|
||||
|
||||
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
|
||||
for l:marker in l:markers
|
||||
if filereadable(l:path . '/' . l:marker)
|
||||
return l:path
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('erlang', {
|
||||
@ -36,5 +54,6 @@ call ale#linter#Define('erlang', {
|
||||
\ 'callback': 'ale_linters#erlang#elvis#Handle',
|
||||
\ 'executable': {b -> ale#Var(b, 'erlang_elvis_executable')},
|
||||
\ 'command': function('s:GetCommand'),
|
||||
\ 'cwd': function('s:GetCwd'),
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
@ -21,7 +21,14 @@ function! s:GetCommand(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! s:FindProjectRoot(buffer) abort
|
||||
let l:markers = ['_build/', 'erlang_ls.config', 'rebar.lock']
|
||||
let l:markers = [
|
||||
\ '_checkouts/',
|
||||
\ '_build/',
|
||||
\ 'deps/',
|
||||
\ 'erlang_ls.config',
|
||||
\ 'rebar.lock',
|
||||
\ 'erlang.mk',
|
||||
\]
|
||||
|
||||
" This is a way to find Erlang/OTP root (the one that is managed
|
||||
" by kerl or asdf). Useful if :ALEGoToDefinition takes us there.
|
||||
|
@ -3,29 +3,13 @@
|
||||
|
||||
call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
|
||||
|
||||
function! ale_linters#erlang#syntaxerl#RunHelpCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'erlang_syntaxerl_executable')
|
||||
|
||||
return ale#command#Run(
|
||||
\ a:buffer,
|
||||
\ ale#Escape(l:executable) . ' -h',
|
||||
\ function('ale_linters#erlang#syntaxerl#GetCommand'),
|
||||
\)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output, meta) abort
|
||||
let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1
|
||||
|
||||
return '%e' . (l:use_b_option ? ' -b %s %t' : ' %t')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v\C:(\d+):( warning:)? (.+)'
|
||||
let l:loclist = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:loclist, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'lnum': str2nr(l:match[1]),
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': empty(l:match[2]) ? 'E' : 'W',
|
||||
\})
|
||||
@ -34,9 +18,27 @@ function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
|
||||
return l:loclist
|
||||
endfunction
|
||||
|
||||
function! s:GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'erlang_syntaxerl_executable')
|
||||
endfunction
|
||||
|
||||
function! s:GetCommand(buffer) abort
|
||||
let l:Callback = function('s:GetCommandFromHelpOutput')
|
||||
|
||||
return ale#command#Run(a:buffer, '%e -h', l:Callback, {
|
||||
\ 'executable': s:GetExecutable(a:buffer),
|
||||
\})
|
||||
endfunction
|
||||
|
||||
function! s:GetCommandFromHelpOutput(buffer, output, metadata) abort
|
||||
let l:has_b_option = match(a:output, '\V\C-b, --base\>') > -1
|
||||
|
||||
return l:has_b_option ? '%e -b %s %t' : '%e %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('erlang', {
|
||||
\ 'name': 'syntaxerl',
|
||||
\ 'executable': {b -> ale#Var(b, 'erlang_syntaxerl_executable')},
|
||||
\ 'command': {b -> ale_linters#erlang#syntaxerl#RunHelpCommand(b)},
|
||||
\ 'callback': 'ale_linters#erlang#syntaxerl#Handle',
|
||||
\ 'executable': function('s:GetExecutable'),
|
||||
\ 'command': function('s:GetCommand'),
|
||||
\})
|
||||
|
Reference in New Issue
Block a user