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:
Jeremy Cantrell 2022-11-07 07:20:25 -06:00 committed by GitHub
parent edffffac25
commit 4b433e5693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 0 deletions

View File

@ -570,6 +570,11 @@ let s:default_registry = {
\ 'function': 'ale#fixers#zigfmt#Fix', \ 'function': 'ale#fixers#zigfmt#Fix',
\ 'suggested_filetypes': ['zig'], \ 'suggested_filetypes': ['zig'],
\ 'description': 'Official formatter for Zig', \ 'description': 'Official formatter for Zig',
\ },
\ 'raco_fmt': {
\ 'function': 'ale#fixers#raco_fmt#Fix',
\ 'suggested_filetypes': ['racket'],
\ 'description': 'Fix Racket files with raco fmt.',
\ } \ }
\} \}

View File

@ -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

View File

@ -497,6 +497,7 @@ Notes:
* Racket * Racket
* `racket-langserver` * `racket-langserver`
* `raco` * `raco`
* `raco_fmt`
* Re:VIEW * Re:VIEW
* `redpen` * `redpen`
* ReasonML * ReasonML

View File

@ -506,6 +506,7 @@ formatting.
* Racket * Racket
* [racket-langserver](https://github.com/jeapostrophe/racket-langserver/tree/master) * [racket-langserver](https://github.com/jeapostrophe/racket-langserver/tree/master)
* [raco](https://docs.racket-lang.org/raco/) * [raco](https://docs.racket-lang.org/raco/)
* [raco_fmt](https://docs.racket-lang.org/fmt/)
* Re:VIEW * Re:VIEW
* [redpen](http://redpen.cc/) * [redpen](http://redpen.cc/)
* ReasonML * ReasonML

View File

@ -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}