summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/javascript/biome.vim10
-rw-r--r--ale_linters/typescript/biome.vim10
-rw-r--r--autoload/ale/fix/registry.vim10
-rw-r--r--autoload/ale/fixers/biome.vim15
-rw-r--r--autoload/ale/handlers/biome.vim33
-rw-r--r--doc/ale-javascript.txt23
-rw-r--r--doc/ale-typescript.txt21
-rw-r--r--supported-tools.md4
-rw-r--r--test/fixers/test_biome_fixer_callback.vader30
-rw-r--r--test/linter/test_typescript_biome.vader14
-rw-r--r--test/test-files/biome/node_modules/.bin/biome0
-rw-r--r--test/test-files/biome/src/test.js0
12 files changed, 91 insertions, 79 deletions
diff --git a/ale_linters/javascript/biome.vim b/ale_linters/javascript/biome.vim
new file mode 100644
index 00000000..71a08114
--- /dev/null
+++ b/ale_linters/javascript/biome.vim
@@ -0,0 +1,10 @@
+" Author: Filip Gospodinov <f@gospodinov.ch>
+" Description: biome for JavaScript files
+
+call ale#linter#Define('javascript', {
+\ 'name': 'biome',
+\ 'lsp': 'stdio',
+\ '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
new file mode 100644
index 00000000..763a254c
--- /dev/null
+++ b/ale_linters/typescript/biome.vim
@@ -0,0 +1,10 @@
+" Author: Filip Gospodinov <f@gospodinov.ch>
+" Description: biome for TypeScript files
+
+call ale#linter#Define('typescript', {
+\ 'name': 'biome',
+\ 'lsp': 'stdio',
+\ 'executable': function('ale#handlers#biome#GetExecutable'),
+\ 'command': function('ale#handlers#biome#GetCommand'),
+\ 'project_root': function('ale#handlers#biome#GetProjectRoot'),
+\})
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
diff --git a/doc/ale-javascript.txt b/doc/ale-javascript.txt
index 98c582da..7e594f2a 100644
--- a/doc/ale-javascript.txt
+++ b/doc/ale-javascript.txt
@@ -28,28 +28,7 @@ To this: >
===============================================================================
biome *ale-javascript-biome*
-g:ale_javascript_biome_executable *g:ale_javascript_biome_executable*
- *b:ale_javascript_biome_executable*
- Type: |String|
- Default: `'biome'`
-
- See |ale-integrations-local-executables|
-
-
-g:ale_javascript_biome_use_global *g:ale_javascript_biome_use_global*
- *b:ale_javascript_biome_use_global*
- Type: |Number|
- Default: `get(g:, 'ale_use_global_executables', 0)`
-
- See |ale-integrations-local-executables|
-
-
-g:ale_javascript_biome_options *g:ale_javascript_biome_options*
- *b:ale_javascript_biome_options*
- Type: |String|
- Default: `''`
-
- This variable can be set to pass additional options to biome.
+Check the docs over at |ale-typescript-biome|.
===============================================================================
diff --git a/doc/ale-typescript.txt b/doc/ale-typescript.txt
index 1641e60e..96899a29 100644
--- a/doc/ale-typescript.txt
+++ b/doc/ale-typescript.txt
@@ -5,7 +5,26 @@ ALE TypeScript Integration *ale-typescript-options*
===============================================================================
biome *ale-typescript-biome*
-See |ale-javascript-biome|
+g:ale_biome_executable *g:ale_biome_executable*
+ *b:ale_biome_executable*
+ Type: |String|
+ Default: `'biome'`
+
+
+g:ale_biome_options *g:ale_biome_options*
+ *b:ale_biome_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be set to pass additional options to biome.
+
+
+g:ale_biome_use_global *g:ale_biome_use_global*
+ *b:ale_biome_use_global*
+ Type: |Number|
+ Default: `get(g:, 'ale_use_global_executables', 0)`
+
+ See |ale-integrations-local-executables|
===============================================================================
diff --git a/supported-tools.md b/supported-tools.md
index 24d67c8f..68635d99 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -302,7 +302,7 @@ formatting.
* [javalsp](https://github.com/georgewfraser/vscode-javac)
* [uncrustify](https://github.com/uncrustify/uncrustify)
* JavaScript
- * [biome](http://biomejs.dev)
+ * [biome](https://biomejs.dev/)
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
* [deno](https://deno.land/)
@@ -666,7 +666,7 @@ formatting.
* TOML
* [dprint](https://dprint.dev)
* TypeScript
- * [biome](http://biomejs.dev)
+ * [biome](https://biomejs.dev/)
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
* [deno](https://deno.land/)
* [dprint](https://dprint.dev/)
diff --git a/test/fixers/test_biome_fixer_callback.vader b/test/fixers/test_biome_fixer_callback.vader
deleted file mode 100644
index 0cb4888e..00000000
--- a/test/fixers/test_biome_fixer_callback.vader
+++ /dev/null
@@ -1,30 +0,0 @@
-Before:
- call ale#assert#SetUpFixerTest('javascript', 'biome')
- runtime autoload/ale/handlers/biome.vim
- set filetype=javascript
-
-After:
- call ale#assert#TearDownFixerTest()
-
-Execute(The biome callback should return the correct default values):
- call ale#test#SetFilename('../test-files/biome/src/test.js')
-
- AssertFixer
- \ {
- \ 'read_temporary_file': 1,
- \ 'command': (has('win32') ? 'node.exe ' : '')
- \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/biome/node_modules/.bin/biome'))
- \ . ' check --apply %t',
- \ }
-
-Execute(The biome callback should include custom biome options):
- let b:ale_javascript_biome_options = '--organize-imports-enabled=true'
- call ale#test#SetFilename('../test-files/biome/src/test.js')
-
- AssertFixer
- \ {
- \ 'read_temporary_file': 1,
- \ 'command': (has('win32') ? 'node.exe ' : '')
- \ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/biome/node_modules/.bin/biome'))
- \ . ' check --apply --organize-imports-enabled=true %t',
- \ }
diff --git a/test/linter/test_typescript_biome.vader b/test/linter/test_typescript_biome.vader
new file mode 100644
index 00000000..95b8fe82
--- /dev/null
+++ b/test/linter/test_typescript_biome.vader
@@ -0,0 +1,14 @@
+Before:
+ call ale#assert#SetUpLinterTest('typescript', 'biome')
+ call ale#test#SetFilename('test.ts')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default biome command should be correct):
+ AssertLinter 'biome', ale#Escape('biome') . ' lsp-proxy'
+
+Execute(The biome command should accept options):
+ let b:ale_biome_options = '--foobar'
+
+ AssertLinter 'biome', ale#Escape('biome') . ' lsp-proxy --foobar'
diff --git a/test/test-files/biome/node_modules/.bin/biome b/test/test-files/biome/node_modules/.bin/biome
deleted file mode 100644
index e69de29b..00000000
--- a/test/test-files/biome/node_modules/.bin/biome
+++ /dev/null
diff --git a/test/test-files/biome/src/test.js b/test/test-files/biome/src/test.js
deleted file mode 100644
index e69de29b..00000000
--- a/test/test-files/biome/src/test.js
+++ /dev/null