mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 05:04:28 +08:00
Fix cwd setting to use .stylua.toml if stylua.toml is not found (#4892)
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:
@@ -8,10 +8,12 @@ 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'
|
||||
if !empty(l:config)
|
||||
return fnamemodify(l:config, ':h')
|
||||
endif
|
||||
endfor
|
||||
|
||||
return ''
|
||||
return '%s:h'
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#stylua#Fix(buffer) abort
|
||||
|
||||
@@ -18,3 +18,21 @@ Execute(The stylua callback should include custom stylua options):
|
||||
\ . ' ' . g:ale_lua_stylua_options
|
||||
\ . ' --stdin-filepath %s -',
|
||||
\ }
|
||||
|
||||
Execute(stylua should detect stylua.toml):
|
||||
call ale#test#SetFilename('../test-files/stylua/stylua_config_dir/subdir/test.lua')
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/stylua/stylua_config_dir'),
|
||||
\ 'command': ale#Escape('stylua') . ' --stdin-filepath %s -',
|
||||
\ }
|
||||
|
||||
Execute(stylua should detect .stylua.toml):
|
||||
call ale#test#SetFilename('../test-files/stylua/stylua_dot_config_dir/subdir/test.lua')
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/stylua/stylua_dot_config_dir'),
|
||||
\ 'command': ale#Escape('stylua') . ' --stdin-filepath %s -',
|
||||
\ }
|
||||
|
||||
Reference in New Issue
Block a user