summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/erbformatter.vim13
-rw-r--r--doc/ale-eruby.txt15
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/fixers/test_erbformatter_fixer_callback.vader19
7 files changed, 54 insertions, 1 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 2f7edba8..a0e0c530 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -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.',
\ }
\}
diff --git a/autoload/ale/fixers/erbformatter.vim b/autoload/ale/fixers/erbformatter.vim
new file mode 100644
index 00000000..7bb43e0c
--- /dev/null
+++ b/autoload/ale/fixers/erbformatter.vim
@@ -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
diff --git a/doc/ale-eruby.txt b/doc/ale-eruby.txt
index 4cf08d07..65bd8a30 100644
--- a/doc/ale-eruby.txt
+++ b/doc/ale-eruby.txt
@@ -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.
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index 2fd84eae..32719729 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -175,6 +175,7 @@ Notes:
* `elm-make`
* Erb
* `erb`
+ * `erb-formatter`
* `erblint`
* `erubi`
* `erubis`
diff --git a/doc/ale.txt b/doc/ale.txt
index 497dde03..06c8dd16 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -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|
diff --git a/supported-tools.md b/supported-tools.md
index 7e41ea65..2cdb878f 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -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)
diff --git a/test/fixers/test_erbformatter_fixer_callback.vader b/test/fixers/test_erbformatter_fixer_callback.vader
new file mode 100644
index 00000000..417a64e8
--- /dev/null
+++ b/test/fixers/test_erbformatter_fixer_callback.vader
@@ -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,
+ \}