mirror of https://github.com/dense-analysis/ale
Add raco_fmt fixer for Racket files (#4354)
* Add raco_fmt fixer for Racket files * Fix command and add test * Fix quoting
This commit is contained in:
parent
edffffac25
commit
4b433e5693
|
@ -570,6 +570,11 @@ let s:default_registry = {
|
|||
\ 'function': 'ale#fixers#zigfmt#Fix',
|
||||
\ 'suggested_filetypes': ['zig'],
|
||||
\ 'description': 'Official formatter for Zig',
|
||||
\ },
|
||||
\ 'raco_fmt': {
|
||||
\ 'function': 'ale#fixers#raco_fmt#Fix',
|
||||
\ 'suggested_filetypes': ['racket'],
|
||||
\ 'description': 'Fix Racket files with raco fmt.',
|
||||
\ }
|
||||
\}
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
" Author: Jeremy Cantrell <jmcantrell@gmail.com>
|
||||
" Description: Integration of raco fmt with ALE.
|
||||
|
||||
call ale#Set('racket_raco_fmt_executable', 'raco')
|
||||
call ale#Set('racket_raco_fmt_options', '')
|
||||
|
||||
function! ale#fixers#raco_fmt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'racket_raco_fmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'racket_raco_fmt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . ' fmt'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options),
|
||||
\}
|
||||
endfunction
|
|
@ -497,6 +497,7 @@ Notes:
|
|||
* Racket
|
||||
* `racket-langserver`
|
||||
* `raco`
|
||||
* `raco_fmt`
|
||||
* Re:VIEW
|
||||
* `redpen`
|
||||
* ReasonML
|
||||
|
|
|
@ -506,6 +506,7 @@ formatting.
|
|||
* Racket
|
||||
* [racket-langserver](https://github.com/jeapostrophe/racket-langserver/tree/master)
|
||||
* [raco](https://docs.racket-lang.org/raco/)
|
||||
* [raco_fmt](https://docs.racket-lang.org/fmt/)
|
||||
* Re:VIEW
|
||||
* [redpen](http://redpen.cc/)
|
||||
* ReasonML
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
Before:
|
||||
call ale#assert#SetUpFixerTest('racket', 'raco_fmt')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
Execute(The raco_fmt callback should return the correct default values):
|
||||
call ale#test#SetFilename('../test-files/racket/simple-script/foo.rkt')
|
||||
|
||||
AssertFixer {'command': ale#Escape('raco') . ' fmt'}
|
||||
|
||||
Execute(The raco_fmt callback should include custom raco_fmt options):
|
||||
let g:ale_racket_raco_fmt_options = "--width 100"
|
||||
call ale#test#SetFilename('../test-files/racket/simple-script/foo.rkt')
|
||||
|
||||
AssertFixer {'command': ale#Escape('raco') . ' fmt ' . g:ale_racket_raco_fmt_options}
|
||||
|
Loading…
Reference in New Issue