]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/biome.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / autoload / ale / handlers / biome.vim
1 " Author: Filip Gospodinov <f@gospodinov.ch>
2 " Description: Functions for working with biome, for checking or fixing files.
3
4 call ale#Set('biome_executable', 'biome')
5 call ale#Set('biome_use_global', get(g:, 'ale_use_global_executables', 0))
6 call ale#Set('biome_options', '')
7 call ale#Set('biome_fixer_apply_unsafe', 0)
8 call ale#Set('biome_lsp_project_root', '')
9
10 function! ale#handlers#biome#GetExecutable(buffer) abort
11     return ale#path#FindExecutable(a:buffer, 'biome', [
12     \   'node_modules/@biomejs/cli-linux-x64/biome',
13     \   'node_modules/@biomejs/cli-linux-arm64/biome',
14     \   'node_modules/@biomejs/cli-win32-x64/biome.exe',
15     \   'node_modules/@biomejs/cli-win32-arm64/biome.exe',
16     \   'node_modules/@biomejs/cli-darwin-x64/biome',
17     \   'node_modules/@biomejs/cli-darwin-arm64/biome',
18     \   'node_modules/.bin/biome',
19     \])
20 endfunction
21
22 function! ale#handlers#biome#GetLanguage(buffer) abort
23     return getbufvar(a:buffer, '&filetype')
24 endfunction
25
26 function! ale#handlers#biome#GetProjectRoot(buffer) abort
27     let l:project_root = ale#Var(a:buffer, 'biome_lsp_project_root')
28
29     if !empty(l:project_root)
30         return l:project_root
31     endif
32
33     let l:possible_project_roots = [
34     \   'biome.json',
35     \   'biome.jsonc',
36     \   'package.json',
37     \   '.git',
38     \   bufname(a:buffer),
39     \]
40
41     for l:possible_root in l:possible_project_roots
42         let l:project_root = ale#path#FindNearestFile(a:buffer, l:possible_root)
43
44         if empty(l:project_root)
45             let l:project_root = ale#path#FindNearestDirectory(a:buffer, l:possible_root)
46         endif
47
48         if !empty(l:project_root)
49             " dir:p expands to /full/path/to/dir/ whereas
50             " file:p expands to /full/path/to/file (no trailing slash)
51             " Appending '/' ensures that :h:h removes the path's last segment
52             " regardless of whether it is a directory or not.
53             return fnamemodify(l:project_root . '/', ':p:h:h')
54         endif
55     endfor
56
57     return ''
58 endfunction