mirror of
https://github.com/dense-analysis/ale
synced 2024-12-17 20:05:31 +00:00
Add erb-formatter support (#4546)
This commit is contained in:
parent
3d10770387
commit
93a4f70414
@ -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.',
|
||||
\ }
|
||||
\}
|
||||
|
||||
|
13
autoload/ale/fixers/erbformatter.vim
Normal file
13
autoload/ale/fixers/erbformatter.vim
Normal 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
|
@ -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.
|
||||
|
@ -175,6 +175,7 @@ Notes:
|
||||
* `elm-make`
|
||||
* Erb
|
||||
* `erb`
|
||||
* `erb-formatter`
|
||||
* `erblint`
|
||||
* `erubi`
|
||||
* `erubis`
|
||||
|
@ -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|
|
||||
|
@ -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)
|
||||
|
19
test/fixers/test_erbformatter_fixer_callback.vader
Normal file
19
test/fixers/test_erbformatter_fixer_callback.vader
Normal 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,
|
||||
\}
|
Loading…
Reference in New Issue
Block a user