-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rubyfmt](https://github.com/fables-tales/rubyfmt) is a formatter for `ruby` code. This commit adds support for `rubyfmt` as a `ruby` fixer (#2991), together with some tests and documentation.
- Loading branch information
Showing
7 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
" Author: Yining <[email protected]> | ||
" Description: support rubyfmt as ALE fixer for Ruby files | ||
|
||
call ale#Set('ruby_rubyfmt_executable', 'rubyfmt') | ||
call ale#Set('ruby_rubyfmt_options', '') | ||
|
||
function! ale#fixers#rubyfmt#Fix(buffer) abort | ||
let l:executable = ale#Var(a:buffer, 'ruby_rubyfmt_executable') | ||
let l:options = ale#Var(a:buffer, 'ruby_rubyfmt_options') | ||
|
||
return { | ||
\ 'command': ale#Escape(l:executable) | ||
\ . (empty(l:options) ? '' : ' ' . l:options) | ||
\} | ||
endfunction | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -560,6 +560,7 @@ Notes: | |
* `reek` | ||
* `rubocop` | ||
* `ruby` | ||
* `rubyfmt` | ||
* `rufo` | ||
* `solargraph` | ||
* `sorbet` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Before: | ||
Save g:ale_ruby_rubyfmt_executable | ||
Save g:ale_ruby_rubyfmt_options | ||
Save &l:expandtab | ||
Save &l:shiftwidth | ||
Save &l:tabstop | ||
|
||
After: | ||
Restore | ||
|
||
Execute(The rubyfmt callback should return 'rubyfmt' as default command): | ||
setlocal noexpandtab | ||
Assert | ||
\ ale#fixers#rubyfmt#Fix(bufnr('')).command =~# '^' . ale#Escape('rubyfmt'), | ||
\ "Default command name is expected to be 'rubyfmt'" | ||
|
||
Execute(The ruby executable and options should be configurable): | ||
let g:ale_ruby_rubyfmt_executable = 'foobar' | ||
let g:ale_ruby_rubyfmt_options = '--some-option' | ||
|
||
AssertEqual | ||
\ { | ||
\ 'command': ale#Escape('foobar') | ||
\ . ' --some-option', | ||
\ }, | ||
\ ale#fixers#rubyfmt#Fix(bufnr('')) |