diff options
author | Braden Kelley <redbmk@gmail.com> | 2024-06-23 22:32:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-24 06:32:24 +0100 |
commit | 5606606b32299832d92050f4e0f5af646d08f47c (patch) | |
tree | a3ad8f0a3c75e46c27fafeffa507d90ea619f64c | |
parent | f2aef2f510f1c4c0efea019e7c2dc36799133689 (diff) | |
download | ale-5606606b32299832d92050f4e0f5af646d08f47c.zip |
fix(biome): send correct language to lsp proxy (#4773)
Since Biome understands `typescriptreact` and `javascriptreact` as
languages, we can send the `filetype` to the LSP, rather than only
sending `typescript` for both `ts` and `tsx` files, or `javascript` for
`js` and `jsx` files.
fixes: #4752
-rw-r--r-- | ale_linters/javascript/biome.vim | 1 | ||||
-rw-r--r-- | ale_linters/typescript/biome.vim | 1 | ||||
-rw-r--r-- | autoload/ale/handlers/biome.vim | 4 | ||||
-rw-r--r-- | test/linter/test_biome.vader (renamed from test/linter/test_typescript_biome.vader) | 17 |
4 files changed, 23 insertions, 0 deletions
diff --git a/ale_linters/javascript/biome.vim b/ale_linters/javascript/biome.vim index 71a08114..61f7c8f4 100644 --- a/ale_linters/javascript/biome.vim +++ b/ale_linters/javascript/biome.vim @@ -4,6 +4,7 @@ call ale#linter#Define('javascript', { \ 'name': 'biome', \ 'lsp': 'stdio', +\ 'language': function('ale#handlers#biome#GetLanguage'), \ 'executable': function('ale#handlers#biome#GetExecutable'), \ 'command': function('ale#handlers#biome#GetCommand'), \ 'project_root': function('ale#handlers#biome#GetProjectRoot'), diff --git a/ale_linters/typescript/biome.vim b/ale_linters/typescript/biome.vim index 763a254c..30115744 100644 --- a/ale_linters/typescript/biome.vim +++ b/ale_linters/typescript/biome.vim @@ -4,6 +4,7 @@ call ale#linter#Define('typescript', { \ 'name': 'biome', \ 'lsp': 'stdio', +\ 'language': function('ale#handlers#biome#GetLanguage'), \ 'executable': function('ale#handlers#biome#GetExecutable'), \ 'command': function('ale#handlers#biome#GetCommand'), \ 'project_root': function('ale#handlers#biome#GetProjectRoot'), diff --git a/autoload/ale/handlers/biome.vim b/autoload/ale/handlers/biome.vim index e8da6a2f..a12bfe83 100644 --- a/autoload/ale/handlers/biome.vim +++ b/autoload/ale/handlers/biome.vim @@ -25,6 +25,10 @@ function! ale#handlers#biome#GetCommand(buffer) abort \ . (!empty(l:options) ? ' ' . l:options : '') endfunction +function! ale#handlers#biome#GetLanguage(buffer) abort + return getbufvar(a:buffer, '&filetype') +endfunction + function! ale#handlers#biome#GetProjectRoot(buffer) abort let l:biome_file = ale#path#FindNearestFile(a:buffer, 'biome.json') diff --git a/test/linter/test_typescript_biome.vader b/test/linter/test_biome.vader index 79bcbebc..c2cd9407 100644 --- a/test/linter/test_typescript_biome.vader +++ b/test/linter/test_biome.vader @@ -16,3 +16,20 @@ Execute(The biome command should accept options): let g:ale_biome_options = '--foobar' AssertLinter 'biome', ale#Escape('biome') . ' lsp-proxy --foobar' + +Execute(Uses the filetype as the language): + call ale#test#SetFilename('test.ts') + set filetype=typescript + AssertLSPLanguage 'typescript' + + call ale#test#SetFilename('test.tsx') + set filetype=typescriptreact + AssertLSPLanguage 'typescriptreact' + + call ale#test#SetFilename('test.js') + set filetype=javascript + AssertLSPLanguage 'javascript' + + call ale#test#SetFilename('test.jsx') + set filetype=javascriptreact + AssertLSPLanguage 'javascriptreact' |