diff --git a/ale_linters/toml/tombi.vim b/ale_linters/toml/tombi.vim index 59c8da40..72b859a0 100644 --- a/ale_linters/toml/tombi.vim +++ b/ale_linters/toml/tombi.vim @@ -4,13 +4,6 @@ call ale#Set('toml_tombi_executable', 'tombi') call ale#Set('toml_tombi_lsp_options', '') -function! ale_linters#toml#tombi#GetCommand(buffer) abort - let l:options = ale#Var(a:buffer, 'toml_tombi_lsp_options') - - return '%e lsp' - \ . (empty(l:options) ? '' : ' ' . l:options) -endfunction - function! ale_linters#toml#tombi#GetProjectRoot(buffer) abort " Try to find nearest tombi.toml let l:tombiconfig_file = ale#path#FindNearestFile(a:buffer, 'tombi.toml') @@ -40,6 +33,6 @@ call ale#linter#Define('toml', { \ 'name': 'tombi', \ 'lsp': 'stdio', \ 'executable': {b -> ale#Var(b, 'toml_tombi_executable')}, -\ 'command': function('ale_linters#toml#tombi#GetCommand'), +\ 'command': {b -> '%e lsp' . ale#Pad(ale#Var(b, 'toml_tombi_lsp_options'))}, \ 'project_root': function('ale_linters#toml#tombi#GetProjectRoot'), \}) diff --git a/autoload/ale/fixers/tombi_format.vim b/autoload/ale/fixers/tombi_format.vim index 730032fa..7574546f 100644 --- a/autoload/ale/fixers/tombi_format.vim +++ b/autoload/ale/fixers/tombi_format.vim @@ -6,11 +6,10 @@ call ale#Set('toml_tombi_format_options', '') function! ale#fixers#tombi_format#Fix(buffer) abort let l:executable = ale#Var(a:buffer, 'toml_tombi_executable') - let l:options = ale#Var(a:buffer, 'toml_tombi_format_options') return { \ 'command': ale#Escape(l:executable) \ . ' format' - \ . (empty(l:options) ? '' : ' ' . l:options), + \ . ale#Pad(ale#Var(a:buffer, 'toml_tombi_format_options')), \} endfunction diff --git a/autoload/ale/fixers/tombi_lint.vim b/autoload/ale/fixers/tombi_lint.vim index 06d90ebf..e128debe 100644 --- a/autoload/ale/fixers/tombi_lint.vim +++ b/autoload/ale/fixers/tombi_lint.vim @@ -6,11 +6,10 @@ call ale#Set('toml_tombi_lint_options', '') function! ale#fixers#tombi_lint#Fix(buffer) abort let l:executable = ale#Var(a:buffer, 'toml_tombi_executable') - let l:options = ale#Var(a:buffer, 'toml_tombi_lint_options') return { \ 'command': ale#Escape(l:executable) \ . ' lint' - \ . (empty(l:options) ? '' : ' ' . l:options), + \ . ale#Pad(ale#Var(a:buffer, 'toml_tombi_lint_options')), \} endfunction diff --git a/test/fixers/test_tombi_format_fixer_callback.vader b/test/fixers/test_tombi_format_fixer_callback.vader index 0807d354..c71b86fe 100644 --- a/test/fixers/test_tombi_format_fixer_callback.vader +++ b/test/fixers/test_tombi_format_fixer_callback.vader @@ -14,20 +14,13 @@ After: call ale#test#RestoreDirectory() Execute(The tombi format callback should return the correct default values): - AssertEqual - \ { - \ 'command': ale#Escape('xxxinvalid') . ' format', - \ }, + \ {'command': ale#Escape('xxxinvalid') . ' format'}, \ ale#fixers#tombi_format#Fix(bufnr('')) Execute(The tombi format callback should include custom options): let g:ale_toml_tombi_format_options = "--offline" AssertEqual - \ { - \ 'command': ale#Escape('xxxinvalid') - \ . ' format' - \ . ' ' . g:ale_toml_tombi_format_options - \ }, + \ {'command': ale#Escape('xxxinvalid') . ' format --offline'}, \ ale#fixers#tombi_format#Fix(bufnr('')) diff --git a/test/fixers/test_tombi_lint_fixer_callback.vader b/test/fixers/test_tombi_lint_fixer_callback.vader index c3d6763e..e1f56175 100644 --- a/test/fixers/test_tombi_lint_fixer_callback.vader +++ b/test/fixers/test_tombi_lint_fixer_callback.vader @@ -14,20 +14,13 @@ After: call ale#test#RestoreDirectory() Execute(The tombi lint callback should return the correct default values): - AssertEqual - \ { - \ 'command': ale#Escape('xxxinvalid') . ' lint', - \ }, + \ {'command': ale#Escape('xxxinvalid') . ' lint'}, \ ale#fixers#tombi_lint#Fix(bufnr('')) Execute(The tombi lint callback should include custom options): let g:ale_toml_tombi_lint_options = "--offline" AssertEqual - \ { - \ 'command': ale#Escape('xxxinvalid') - \ . ' lint' - \ . ' ' . g:ale_toml_tombi_lint_options - \ }, + \ {'command': ale#Escape('xxxinvalid') . ' lint --offline'}, \ ale#fixers#tombi_lint#Fix(bufnr('')) diff --git a/test/linter/test_toml_tombi.vader b/test/linter/test_toml_tombi.vader index 70fa1d00..f036cef0 100644 --- a/test/linter/test_toml_tombi.vader +++ b/test/linter/test_toml_tombi.vader @@ -16,8 +16,3 @@ Execute(The project root should be detected correctly in Python projects): call ale#test#SetFilename('../test-files/toml/tombi/pyprojecttoml/subdir/file.ext') AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/toml/tombi/pyprojecttoml') - -Execute(The project root should be empty when no project files can be detected): - call ale#test#SetFilename('../test-files/dummy') - - AssertLSPProject ''