mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 20:54:26 +08:00
fix: stylua should have cwd and --stdin-filepath (#4873)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--neovim-06-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--neovim-06-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
This commit is contained in:
@@ -4,11 +4,22 @@
|
|||||||
call ale#Set('lua_stylua_executable', 'stylua')
|
call ale#Set('lua_stylua_executable', 'stylua')
|
||||||
call ale#Set('lua_stylua_options', '')
|
call ale#Set('lua_stylua_options', '')
|
||||||
|
|
||||||
|
function! ale#fixers#stylua#GetCwd(buffer) abort
|
||||||
|
for l:possible_configfile in ['stylua.toml', '.stylua.toml']
|
||||||
|
let l:config = ale#path#FindNearestFile(a:buffer, l:possible_configfile)
|
||||||
|
|
||||||
|
return !empty(l:config) ? fnamemodify(l:config, ':h') : '%s:h'
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale#fixers#stylua#Fix(buffer) abort
|
function! ale#fixers#stylua#Fix(buffer) abort
|
||||||
let l:executable = ale#Var(a:buffer, 'lua_stylua_executable')
|
let l:executable = ale#Var(a:buffer, 'lua_stylua_executable')
|
||||||
let l:options = ale#Var(a:buffer, 'lua_stylua_options')
|
let l:options = ale#Var(a:buffer, 'lua_stylua_options')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
\ 'command': ale#Escape(l:executable) . ale#Pad(l:options) . ' -',
|
\ 'cwd': ale#fixers#stylua#GetCwd(a:buffer),
|
||||||
|
\ 'command': ale#Escape(l:executable) . ale#Pad(l:options) . ' --stdin-filepath %s -',
|
||||||
\}
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ After:
|
|||||||
call ale#assert#TearDownFixerTest()
|
call ale#assert#TearDownFixerTest()
|
||||||
|
|
||||||
Execute(The default command should be correct):
|
Execute(The default command should be correct):
|
||||||
AssertFixer {'command': ale#Escape('stylua') . ' -'}
|
AssertFixer {'cwd': '%s:h', 'command': ale#Escape('stylua') . ' --stdin-filepath %s -'}
|
||||||
|
|
||||||
Execute(The stylua callback should include custom stylua options):
|
Execute(The stylua callback should include custom stylua options):
|
||||||
let g:ale_lua_stylua_executable = 'xxxinvalid'
|
let g:ale_lua_stylua_executable = 'xxxinvalid'
|
||||||
@@ -13,7 +13,8 @@ Execute(The stylua callback should include custom stylua options):
|
|||||||
|
|
||||||
AssertFixer
|
AssertFixer
|
||||||
\ {
|
\ {
|
||||||
|
\ 'cwd': '%s:h',
|
||||||
\ 'command': ale#Escape('xxxinvalid')
|
\ 'command': ale#Escape('xxxinvalid')
|
||||||
\ . ' ' . g:ale_lua_stylua_options
|
\ . ' ' . g:ale_lua_stylua_options
|
||||||
\ . ' -',
|
\ . ' --stdin-filepath %s -',
|
||||||
\ }
|
\ }
|
||||||
|
|||||||
Reference in New Issue
Block a user