feat: Add Deno fmt fixer
This commit is contained in:
parent
33f2f8ddcd
commit
4f2666265a
4 changed files with 50 additions and 0 deletions
|
@ -32,6 +32,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['python'],
|
\ 'suggested_filetypes': ['python'],
|
||||||
\ 'description': 'Fix PEP8 issues with black.',
|
\ 'description': 'Fix PEP8 issues with black.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'deno': {
|
||||||
|
\ 'function': 'ale#fixers#deno#Fix',
|
||||||
|
\ 'suggested_filetypes': ['typescript'],
|
||||||
|
\ 'description': 'Fix TypeScript using deno fmt.',
|
||||||
|
\ },
|
||||||
\ 'dfmt': {
|
\ 'dfmt': {
|
||||||
\ 'function': 'ale#fixers#dfmt#Fix',
|
\ 'function': 'ale#fixers#dfmt#Fix',
|
||||||
\ 'suggested_filetypes': ['d'],
|
\ 'suggested_filetypes': ['d'],
|
||||||
|
|
17
autoload/ale/fixers/deno.vim
Normal file
17
autoload/ale/fixers/deno.vim
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
function! ale#fixers#deno#Fix(buffer) abort
|
||||||
|
let l:executable = ale#handlers#deno#GetExecutable(a:buffer)
|
||||||
|
|
||||||
|
if !executable(l:executable)
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:options = ' fmt -'
|
||||||
|
|
||||||
|
if ale#Var(a:buffer, 'deno_unstable')
|
||||||
|
let l:options = l:options . ' --unstable'
|
||||||
|
endif
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable) . l:options
|
||||||
|
\}
|
||||||
|
endfunction
|
9
autoload/ale/handlers/deno.vim
Normal file
9
autoload/ale/handlers/deno.vim
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
" Author: Mohammed Chelouti - https://github.com/motato1
|
||||||
|
" Description: Handler functions for Deno.
|
||||||
|
|
||||||
|
call ale#Set('deno_executable', 'deno')
|
||||||
|
call ale#Set('deno_unstable', 0)
|
||||||
|
|
||||||
|
function! ale#handlers#deno#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'deno_executable')
|
||||||
|
endfunction
|
19
test/test_deno_executable_detection.vader
Normal file
19
test/test_deno_executable_detection.vader
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
Before:
|
||||||
|
runtime autoload/ale/handlers/deno.vim
|
||||||
|
|
||||||
|
After:
|
||||||
|
unlet! g:ale_deno_executable
|
||||||
|
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
|
Execute(Default executable should be detected correctly):
|
||||||
|
AssertEqual
|
||||||
|
\ 'deno',
|
||||||
|
\ ale#handlers#deno#GetExecutable(bufnr(''))
|
||||||
|
|
||||||
|
Execute(User specified executable should override default):
|
||||||
|
let g:ale_deno_executable = '/path/to/deno-bin'
|
||||||
|
AssertEqual
|
||||||
|
\ '/path/to/deno-bin',
|
||||||
|
\ ale#handlers#deno#GetExecutable(bufnr(''))
|
||||||
|
|
Reference in a new issue