diff options
author | ohakutsu <dev@ohakutsu.com> | 2024-01-14 21:05:38 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-14 21:05:38 +0900 |
commit | 531970533a51557ae6a4614ec6a2fbae243a6c6b (patch) | |
tree | eb4163821a5e6d960d7d50376d584268079e5d9a | |
parent | 94f764631d6f04d3c9293399be2a7e941fc65f5d (diff) | |
download | ale-531970533a51557ae6a4614ec6a2fbae243a6c6b.zip |
Add language id of cspell (#4700)
-rw-r--r-- | autoload/ale/handlers/cspell.vim | 4 | ||||
-rw-r--r-- | test/linter/test_cspell.vader | 20 |
2 files changed, 19 insertions, 5 deletions
diff --git a/autoload/ale/handlers/cspell.vim b/autoload/ale/handlers/cspell.vim index 6137bdeb..605997ce 100644 --- a/autoload/ale/handlers/cspell.vim +++ b/autoload/ale/handlers/cspell.vim @@ -14,9 +14,13 @@ endfunction function! ale#handlers#cspell#GetCommand(buffer) abort let l:executable = ale#handlers#cspell#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'cspell_options') + let l:filetype = getbufvar(a:buffer, '&filetype') + + let l:language_id_option = empty(l:filetype) ? '' : '--language-id="' . l:filetype . '"' return ale#node#Executable(a:buffer, l:executable) \ . ' lint --no-color --no-progress --no-summary' + \ . ale#Pad(l:language_id_option) \ . ale#Pad(l:options) \ . ' -- stdin' endfunction diff --git a/test/linter/test_cspell.vader b/test/linter/test_cspell.vader index 48dee7ce..17cbde89 100644 --- a/test/linter/test_cspell.vader +++ b/test/linter/test_cspell.vader @@ -20,6 +20,8 @@ Before: let g:ale_cspell_use_global = 0 let g:ale_cspell_options = '' + set filetype=tex + After: call ale#assert#TearDownLinterTest() @@ -27,7 +29,7 @@ Execute(The global executable should be used when the local one cannot be found) AssertLinter \ 'cspell', \ ale#Escape('cspell') - \ . ' lint --no-color --no-progress --no-summary -- stdin' + \ . ' lint --no-color --no-progress --no-summary --language-id="tex" -- stdin' Execute(Should use the node_modules/.bin executable if available): call ale#test#SetFilename('../test-files/cspell/node-modules/test.tex') @@ -37,7 +39,7 @@ Execute(Should use the node_modules/.bin executable if available): \ . '/../test-files/cspell/node-modules/node_modules/.bin/cspell'), \ ale#Escape(ale#path#Simplify(g:dir \ . '/../test-files/cspell/node-modules/node_modules/.bin/cspell')) - \ . ' lint --no-color --no-progress --no-summary -- stdin' + \ . ' lint --no-color --no-progress --no-summary --language-id="tex" -- stdin' Execute(Should use the node_modules/cspell executable if available): call ale#test#SetFilename('../test-files/cspell/node-modules-2/test.tex') @@ -48,7 +50,7 @@ Execute(Should use the node_modules/cspell executable if available): \ (has('win32') ? 'node.exe ': '') \ . ale#Escape(ale#path#Simplify(g:dir \ . '/../test-files/cspell/node-modules-2/node_modules/cspell/bin.js')) - \ . ' lint --no-color --no-progress --no-summary -- stdin' + \ . ' lint --no-color --no-progress --no-summary --language-id="tex" -- stdin' Execute(Should let users configure a global executable and override local paths): let g:ale_cspell_executable = '/path/to/custom/cspell' @@ -57,7 +59,7 @@ Execute(Should let users configure a global executable and override local paths) AssertLinter \ '/path/to/custom/cspell', \ ale#Escape('/path/to/custom/cspell') - \ . ' lint --no-color --no-progress --no-summary -- stdin' + \ . ' lint --no-color --no-progress --no-summary --language-id="tex" -- stdin' Execute(Additional cspell options should be configurable): call ale#test#SetFilename('../test-files/dummy') @@ -67,4 +69,12 @@ Execute(Additional cspell options should be configurable): AssertLinter \ 'cspell', \ ale#Escape('cspell') - \ . ' lint --no-color --no-progress --no-summary --foobar -- stdin' + \ . ' lint --no-color --no-progress --no-summary --language-id="tex" --foobar -- stdin' + +Execute(The language id should not specified when filetype is empty): + set filetype= + + AssertLinter + \ 'cspell', + \ ale#Escape('cspell') + \ . ' lint --no-color --no-progress --no-summary -- stdin' |