mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Add full support for biome (#4705)
* Revert "Add biome support for javascript (#4701)"
This reverts commit 8922478a83.
* Add support for biome
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user