add: support for rubyfmt as ruby fixer (#4678)

[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.
This commit is contained in:
Yining
2024-01-14 22:59:20 +11:00
committed by GitHub
parent 17cca243e3
commit 3dbf0b2202
7 changed files with 68 additions and 0 deletions

View File

@@ -641,6 +641,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['nickel'],
\ 'description': 'Fix nickel files with nickel format',
\ },
\ 'rubyfmt': {
\ 'function': 'ale#fixers#rubyfmt#Fix',
\ 'suggested_filetypes': ['ruby'],
\ 'description': 'A formatter for Ruby source code',
\ },
\}
" Reset the function registry to the default entries.

View File

@@ -0,0 +1,16 @@
" Author: Yining <zhang.yining@gmail.com>
" 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