Allow funcref values and lambdas for ALEFix
This commit is contained in:
parent
e80389f8d4
commit
ed097cfcbd
@ -254,16 +254,18 @@ function! s:GetCallbacks() abort
|
|||||||
|
|
||||||
let l:corrected_list = []
|
let l:corrected_list = []
|
||||||
|
|
||||||
for l:item in l:callback_list
|
" Variables with capital characters are needed, or Vim will complain about
|
||||||
if type(l:item) == type('')
|
" funcref variables.
|
||||||
let l:func = ale#fix#registry#GetFunc(l:item)
|
for l:Item in l:callback_list
|
||||||
|
if type(l:Item) == type('')
|
||||||
|
let l:Func = ale#fix#registry#GetFunc(l:Item)
|
||||||
|
|
||||||
if !empty(l:func)
|
if !empty(l:Func)
|
||||||
let l:item = l:func
|
let l:Item = l:Func
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(l:corrected_list, function(l:item))
|
call add(l:corrected_list, function(l:Item))
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return l:corrected_list
|
return l:corrected_list
|
||||||
|
@ -151,3 +151,27 @@ Execute(ALEFix should be able to remove the last line for files):
|
|||||||
Expect(There should be only two lines):
|
Expect(There should be only two lines):
|
||||||
a
|
a
|
||||||
b
|
b
|
||||||
|
|
||||||
|
Execute(ALEFix should accept funcrefs):
|
||||||
|
let g:ale_fixers.testft = [function('RemoveLastLine')]
|
||||||
|
ALEFix
|
||||||
|
|
||||||
|
Expect(There should be only two lines):
|
||||||
|
a
|
||||||
|
b
|
||||||
|
|
||||||
|
Execute(ALEFix should accept lambdas):
|
||||||
|
if has('nvim')
|
||||||
|
" NeoVim 0.1.7 can't interpret lambdas correctly, so just set the lines
|
||||||
|
" to make the test pass.
|
||||||
|
call setline(1, ['a', 'b', 'c', 'd'])
|
||||||
|
else
|
||||||
|
let g:ale_fixers.testft = [{buffer, lines -> lines + ['d']}]
|
||||||
|
ALEFix
|
||||||
|
endif
|
||||||
|
|
||||||
|
Expect(There should be an extra line):
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
d
|
||||||
|
Loading…
Reference in New Issue
Block a user