diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 10 | ||||
-rw-r--r-- | autoload/ale/fixers/biome.vim | 15 | ||||
-rw-r--r-- | autoload/ale/handlers/biome.vim | 33 |
3 files changed, 34 insertions, 24 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index e7b48b45..88468371 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -37,6 +37,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['bib'], \ 'description': 'Format bib files using bibclean.', \ }, +\ 'biome': { +\ 'function': 'ale#fixers#biome#Fix', +\ 'suggested_filetypes': ['javascript', 'typescript'], +\ 'description': 'Fix JavaScript and TypeScript using biome.', +\ }, \ 'black': { \ 'function': 'ale#fixers#black#Fix', \ 'suggested_filetypes': ['python'], @@ -651,11 +656,6 @@ let s:default_registry = { \ 'suggested_filetypes': ['ruby'], \ 'description': 'A formatter for Ruby source code', \ }, -\ 'biome': { -\ 'function': 'ale#fixers#biome#Fix', -\ 'suggested_filetypes': ['javascript', 'typescript'], -\ 'description': 'Apply biome (ex. rome) check to a file.', -\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/biome.vim b/autoload/ale/fixers/biome.vim index 3a45fa3e..903d7f39 100644 --- a/autoload/ale/fixers/biome.vim +++ b/autoload/ale/fixers/biome.vim @@ -1,17 +1,10 @@ -" Author: Akiomi Kamakura <akiomik@gmail.com> -" Description: Fixing files with biome (ex.rome). - function! ale#fixers#biome#Fix(buffer) abort let l:executable = ale#handlers#biome#GetExecutable(a:buffer) - let l:options = ale#Var(a:buffer, 'javascript_biome_options') - let l:node = ale#Var(a:buffer, 'javascript_biome_node_executable') + let l:options = ale#Var(a:buffer, 'biome_options') return { - \ 'command': (has('win32') ? (ale#Escape(l:node) . ' ') : '') - \ . ale#Escape(l:executable) - \ . ' check --apply' - \ . ale#Pad(l:options) - \ . ' %t', - \ 'read_temporary_file': 1, + \ 'command': '%e format' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin-file-path=%s', \} endfunction diff --git a/autoload/ale/handlers/biome.vim b/autoload/ale/handlers/biome.vim index 8d75e3bc..cec98458 100644 --- a/autoload/ale/handlers/biome.vim +++ b/autoload/ale/handlers/biome.vim @@ -1,14 +1,31 @@ -" Author: Akiomi Kamakura <akiomik@gmail.com> -" Description: Functions for working with biome, for fixing files. +" Author: Filip Gospodinov <f@gospodinov.ch> +" Description: Functions for working with biome, for checking or fixing files. -call ale#Set('javascript_biome_node_executable', 'node.exe') -call ale#Set('javascript_biome_executable', 'biome') -call ale#Set('javascript_biome_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('javascript_biome_options', '') +call ale#Set('biome_executable', 'biome') +call ale#Set('biome_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('biome_options', '') function! ale#handlers#biome#GetExecutable(buffer) abort - return ale#path#FindExecutable(a:buffer, 'javascript_biome', [ + return ale#path#FindExecutable(a:buffer, 'biome', [ + \ 'node_modules/@biomejs/cli-linux-x64/biome', + \ 'node_modules/@biomejs/cli-linux-arm64/biome', + \ 'node_modules/@biomejs/cli-win32-x64/biome.exe', + \ 'node_modules/@biomejs/cli-win32-arm64/biome.exe', + \ 'node_modules/@biomejs/cli-darwin-x64/biome', + \ 'node_modules/@biomejs/cli-darwin-arm64/biome', \ 'node_modules/.bin/biome', - \ 'node_modules/@biomejs/biome/bin/biome', \]) 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#GetProjectRoot(buffer) abort + let l:biome_file = ale#path#FindNearestFile(a:buffer, 'biome.json') + + return !empty(l:biome_file) ? fnamemodify(l:biome_file, ':h') : '' +endfunction |