Skip to content

Commit

Permalink
fix!(biome): allow passing options to biome check (dense-analysis#4799
Browse files Browse the repository at this point in the history
)

The only option available to biome's `lsp-proxy` command used for
linting is `--config-path`. However, we are using ALE to find and set
the project root, and have a way to manually override, so that is no
longer necessary.

The LSP proxy also used the `g:ale_biome_options` config, which is
shared with the fixer's `check` command, but `lsp-proxy` will throw an
error if unknown options are included, making it so that option is only
useful to set the project root.

BREAKING CHANGE: We are no longer passing options to the biome LSP
proxy, but we can still set the project root with
`g:ale_biome_lsp_project_root`.
  • Loading branch information
redbmk authored Jun 27, 2024
1 parent ed0b036 commit a0ad5f9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ale_linters/javascript/biome.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ call ale#linter#Define('javascript', {
\ 'lsp': 'stdio',
\ 'language': function('ale#handlers#biome#GetLanguage'),
\ 'executable': function('ale#handlers#biome#GetExecutable'),
\ 'command': function('ale#handlers#biome#GetCommand'),
\ 'command': '%e lsp-proxy',
\ 'project_root': function('ale#handlers#biome#GetProjectRoot'),
\})
2 changes: 1 addition & 1 deletion ale_linters/typescript/biome.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ call ale#linter#Define('typescript', {
\ 'lsp': 'stdio',
\ 'language': function('ale#handlers#biome#GetLanguage'),
\ 'executable': function('ale#handlers#biome#GetExecutable'),
\ 'command': function('ale#handlers#biome#GetCommand'),
\ 'command': '%e lsp-proxy',
\ 'project_root': function('ale#handlers#biome#GetProjectRoot'),
\})
7 changes: 0 additions & 7 deletions autoload/ale/handlers/biome.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ function! ale#handlers#biome#GetExecutable(buffer) abort
\])
endfunction

function! ale#handlers#biome#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'biome_options')

return '%e lsp-proxy'
\ . (!empty(l:options) ? ' ' . l:options : '')
endfunction

function! ale#handlers#biome#GetLanguage(buffer) abort
return getbufvar(a:buffer, '&filetype')
endfunction
Expand Down
3 changes: 2 additions & 1 deletion doc/ale-typescript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ g:ale_biome_options *g:ale_biome_options*
Type: |String|
Default: `''`

This variable can be set to pass additional options to biome.
This variable can be set to pass additional options to `biome check` when
applying fixes.


g:ale_biome_use_global *g:ale_biome_use_global*
Expand Down
15 changes: 13 additions & 2 deletions test/fixers/test_biome_fixer_callback.vader
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ After:
call ale#assert#TearDownFixerTest()

Execute(The default biome command should be correct):
call ale#test#SetFilename('../test-files/typescript/test.ts')
call ale#test#SetFilename('../test-files/biome/jsonc/src/test.ts')

AssertFixer
\ {
Expand All @@ -21,7 +21,7 @@ Execute(The default biome command should be correct):
\ }

Execute(Unsafe fixes can be applied via an option):
call ale#test#SetFilename('../test-files/typescript/test.ts')
call ale#test#SetFilename('../test-files/biome/jsonc/src/test.ts')
let g:ale_biome_fixer_apply_unsafe = 1

AssertFixer
Expand All @@ -30,3 +30,14 @@ Execute(Unsafe fixes can be applied via an option):
\ 'command': ale#Escape('biome')
\ . ' check --apply-unsafe %t'
\ }

Execute(The fixer should accept options):
call ale#test#SetFilename('../test-files/biome/jsonc/src/test.ts')
let g:ale_biome_options = '--foobar'

AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('biome')
\ . ' check --apply --foobar %t',
\ }
5 changes: 0 additions & 5 deletions test/linter/test_biome.vader
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ After:
Execute(The default biome command should be correct):
AssertLinter 'biome', ale#Escape('biome') . ' lsp-proxy'

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
Expand Down

0 comments on commit a0ad5f9

Please sign in to comment.