Add erb-formatter support (#4546)

This commit is contained in:
Arash Mousavi 2023-07-24 13:38:52 +01:00 committed by GitHub
parent 3d10770387
commit 93a4f70414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 1 deletions

View File

@ -615,6 +615,11 @@ let s:default_registry = {
\ 'function': 'ale#fixers#npmgroovylint#Fix',
\ 'suggested_filetypes': ['groovy'],
\ 'description': 'Fix Groovy files with npm-groovy-fix.',
\ },
\ 'erb-formatter': {
\ 'function': 'ale#fixers#erbformatter#Fix',
\ 'suggested_filetypes': ['eruby'],
\ 'description': 'Apply erb-formatter -w to eruby/erb files.',
\ }
\}

View File

@ -0,0 +1,13 @@
" Author: Arash Mousavi <arash-m>
" Description: Support for ERB::Formetter https://github.com/nebulab/erb-formatter
call ale#Set('eruby_erbformatter_executable', 'erb-formatter')
function! ale#fixers#erbformatter#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'eruby_erbformatter_executable')
return {
\ 'command': ale#Escape(l:executable) . ' -w %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -14,6 +14,19 @@ default parser in Rails between 3.0 and 5.1. `erubi` is the default in Rails
5.1 and later. `ruumba` can extract Ruby from eruby files and run rubocop on
the result. To selectively enable a subset, see |g:ale_linters|.
===============================================================================
erb-formatter *ale-eruby-erbformatter*
g:ale_eruby_erbformatter_executable *g:ale_eruby_erbformatter_executable*
*b:ale_eruby_erbformatter_executable*
Type: |String|
Default: `'erb-formatter'`
Override the invoked erb-formatter binary. This is useful for running
erb-formatter from binstubs or a bundle.
===============================================================================
erblint *ale-eruby-erblint*
@ -40,7 +53,7 @@ ruumba *ale-eruby-ruumba*
g:ale_eruby_ruumba_executable *g:ale_eruby_ruumba_executable*
*b:ale_eruby_ruumba_executable*
Type: |String|
Default: `'ruumba`
Default: `'ruumba'`
Override the invoked ruumba binary. This is useful for running ruumba
from binstubs or a bundle.

View File

@ -175,6 +175,7 @@ Notes:
* `elm-make`
* Erb
* `erb`
* `erb-formatter`
* `erblint`
* `erubi`
* `erubis`

View File

@ -2963,6 +2963,7 @@ documented in additional help files.
erlfmt................................|ale-erlang-erlfmt|
syntaxerl.............................|ale-erlang-syntaxerl|
eruby...................................|ale-eruby-options|
erb-formatter.........................|ale-eruby-erbformatter|
erblint...............................|ale-eruby-erblint|
ruumba................................|ale-eruby-ruumba|
fish....................................|ale-fish-options|

View File

@ -184,6 +184,7 @@ formatting.
* [elm-make](https://github.com/elm/compiler)
* Erb
* [erb](https://apidock.com/ruby/ERB)
* [erb-formatter](https://github.com/nebulab/erb-formatter)
* [erblint](https://github.com/Shopify/erb-lint)
* [erubi](https://github.com/jeremyevans/erubi)
* [erubis](https://github.com/kwatch/erubis)

View File

@ -0,0 +1,19 @@
Before:
call ale#assert#SetUpFixerTest('eruby', 'erb-formatter')
After:
call ale#assert#TearDownFixerTest()
Execute(The erb-formatter callback should return the correct default values):
AssertFixer {
\ 'command': ale#Escape('erb-formatter') . ' -w %t',
\ 'read_temporary_file': 1,
\}
Execute(The erb-formatter callback should allow custom erb-formatter executables):
let g:ale_eruby_erbformatter_executable = 'foo/bar'
AssertFixer {
\ 'command': ale#Escape('foo/bar') . ' -w %t',
\ 'read_temporary_file': 1,
\}