summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorAkiomi Kamakura <akiomik@gmail.com>2024-01-14 21:11:14 +0900
committerGitHub <noreply@github.com>2024-01-14 21:11:14 +0900
commit8922478a83cd06bfe5b82eb45279649adc4ec046 (patch)
treeca079044e37108fc06678ed437b27c8ea4f8fbc5 /autoload
parent531970533a51557ae6a4614ec6a2fbae243a6c6b (diff)
downloadale-8922478a83cd06bfe5b82eb45279649adc4ec046.zip
Add biome support for javascript (#4701)
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/biome.vim17
-rw-r--r--autoload/ale/handlers/biome.vim14
3 files changed, 36 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 0cad0a99..044a14d5 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -646,6 +646,11 @@ 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
new file mode 100644
index 00000000..3a45fa3e
--- /dev/null
+++ b/autoload/ale/fixers/biome.vim
@@ -0,0 +1,17 @@
+" 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')
+
+ return {
+ \ 'command': (has('win32') ? (ale#Escape(l:node) . ' ') : '')
+ \ . ale#Escape(l:executable)
+ \ . ' check --apply'
+ \ . ale#Pad(l:options)
+ \ . ' %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/autoload/ale/handlers/biome.vim b/autoload/ale/handlers/biome.vim
new file mode 100644
index 00000000..8d75e3bc
--- /dev/null
+++ b/autoload/ale/handlers/biome.vim
@@ -0,0 +1,14 @@
+" Author: Akiomi Kamakura <akiomik@gmail.com>
+" Description: Functions for working with biome, for 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', '')
+
+function! ale#handlers#biome#GetExecutable(buffer) abort
+ return ale#path#FindExecutable(a:buffer, 'javascript_biome', [
+ \ 'node_modules/.bin/biome',
+ \ 'node_modules/@biomejs/biome/bin/biome',
+ \])
+endfunction