mirror of
https://github.com/amix/vimrc
synced 2025-08-07 22:35:01 +08:00
Updated plugins
This commit is contained in:
40
sources_non_forked/ale/autoload/ale/fixers/erblint.vim
Normal file
40
sources_non_forked/ale/autoload/ale/fixers/erblint.vim
Normal file
@ -0,0 +1,40 @@
|
||||
" Author: Roeland Moors - https://github.com/roelandmoors
|
||||
" Description: ERB Lint, support for https://github.com/Shopify/erb-lint
|
||||
|
||||
call ale#Set('eruby_erblint_executable', 'erblint')
|
||||
call ale#Set('eruby_erblint_options', '')
|
||||
|
||||
|
||||
" Erblint fixer outputs diagnostics first and then the fixed
|
||||
" output. These are delimited by something like this:
|
||||
" ================ /path/to/demo.html.erb ==================
|
||||
" We only need the output after this
|
||||
function! ale#fixers#erblint#PostProcess(buffer, output) abort
|
||||
let l:line = 0
|
||||
|
||||
for l:output in a:output
|
||||
let l:line = l:line + 1
|
||||
|
||||
if l:output =~# "^=\\+.*=\\+$"
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
return a:output[l:line :]
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#erblint#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'eruby_erblint_executable')
|
||||
let l:options = ale#Var(a:buffer, 'eruby_erblint_options')
|
||||
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'erblint')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --autocorrect --stdin %s'
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#erblint#Fix(buffer) abort
|
||||
return {
|
||||
\ 'command': ale#fixers#erblint#GetCommand(a:buffer),
|
||||
\ 'process_with': 'ale#fixers#erblint#PostProcess'
|
||||
\}
|
||||
endfunction
|
@ -21,7 +21,7 @@ function! ale#fixers#isort#GetExecutable(buffer) abort
|
||||
return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort'])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#isort#Fix(buffer) abort
|
||||
function! ale#fixers#isort#GetCmd(buffer) abort
|
||||
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
@ -29,7 +29,20 @@ function! ale#fixers#isort#Fix(buffer) abort
|
||||
call extend(l:cmd, ['run', 'isort'])
|
||||
endif
|
||||
|
||||
call add(l:cmd, '--filename %s')
|
||||
return join(l:cmd, ' ')
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#isort#FixForVersion(buffer, version) abort
|
||||
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
if l:executable =~? 'pipenv\|poetry$'
|
||||
call extend(l:cmd, ['run', 'isort'])
|
||||
endif
|
||||
|
||||
if ale#semver#GTE(a:version, [5, 7, 0])
|
||||
call add(l:cmd, '--filename %s')
|
||||
endif
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'python_isort_options')
|
||||
|
||||
@ -41,6 +54,18 @@ function! ale#fixers#isort#Fix(buffer) abort
|
||||
|
||||
return {
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': join(l:cmd, ' ')
|
||||
\ 'command': join(l:cmd, ' '),
|
||||
\}
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#isort#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
|
||||
let l:command = ale#fixers#isort#GetCmd(a:buffer) . ale#Pad('--version')
|
||||
|
||||
return ale#semver#RunWithVersionCheck(
|
||||
\ a:buffer,
|
||||
\ l:executable,
|
||||
\ l:command,
|
||||
\ function('ale#fixers#isort#FixForVersion'),
|
||||
\)
|
||||
endfunction
|
||||
|
Reference in New Issue
Block a user