File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 44call ale#Set (' lua_stylua_executable' , ' stylua' )
55call ale#Set (' lua_stylua_options' , ' ' )
66
7+ function ! ale#fixers#stylua#GetCwd (buffer ) abort
8+ for l: possible_configfile in [' stylua.toml' , ' .stylua.toml' ]
9+ let l: config = ale#path#FindNearestFile (a: buffer , l: possible_configfile )
10+
11+ return ! empty (l: config ) ? fnamemodify (l: config , ' :h' ) : ' %s:h'
12+ endfor
13+
14+ return ' '
15+ endfunction
16+
717function ! ale#fixers#stylua#Fix (buffer ) abort
818 let l: executable = ale#Var (a: buffer , ' lua_stylua_executable' )
919 let l: options = ale#Var (a: buffer , ' lua_stylua_options' )
1020
1121 return {
12- \ ' command' : ale#Escape (l: executable ) . ale#Pad (l: options ) . ' -' ,
22+ \ ' cwd' : ale#fixers#stylua#GetCwd (a: buffer ),
23+ \ ' command' : ale#Escape (l: executable ) . ale#Pad (l: options ) . ' --stdin-filepath %s -' ,
1324 \}
1425endfunction
Original file line number Diff line number Diff line change 55 call ale#assert#TearDownFixerTest()
66
77Execute(The default command should be correct):
8- AssertFixer {'command': ale#Escape('stylua') . ' -'}
8+ AssertFixer {'cwd': '%s:h', ' command': ale#Escape('stylua') . ' --stdin-filepath %s -'}
99
1010Execute(The stylua callback should include custom stylua options):
1111 let g:ale_lua_stylua_executable = 'xxxinvalid'
1212 let g:ale_lua_stylua_options = '--search-parent-directories'
1313
1414 AssertFixer
1515 \ {
16+ \ 'cwd': '%s:h',
1617 \ 'command': ale#Escape('xxxinvalid')
1718 \ . ' ' . g:ale_lua_stylua_options
18- \ . ' -',
19+ \ . ' --stdin-filepath %s - ',
1920 \ }
You can’t perform that action at this time.
0 commit comments