summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArash Mousavi <me@amousavi.dev>2024-04-17 15:58:28 +0100
committerGitHub <noreply@github.com>2024-04-17 23:58:28 +0900
commit7516e2e4849fb633555d5d40c2137e585ed10b64 (patch)
tree497048b39492215b29c17ce54e8b9397bb3bef83
parent6db58b33795430a6165f27c7f796c420c0e098e4 (diff)
downloadale-7516e2e4849fb633555d5d40c2137e585ed10b64.zip
Add htmlbeautifier support (#4751)
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/htmlbeautifier.vim13
-rw-r--r--doc/ale-eruby.txt13
-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_htmlbeautifier_fixer_callback.vader19
7 files changed, 53 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 141276a0..b8829a5e 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -561,6 +561,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['html', 'htmldjango'],
\ 'description': 'Fix HTML files with html-beautify from js-beautify.',
\ },
+\ 'htmlbeautifier': {
+\ 'function': 'ale#fixers#htmlbeautifier#Fix',
+\ 'suggested_filetypes': ['eruby'],
+\ 'description': 'Fix ERB files with htmlbeautifier gem.',
+\ },
\ 'lua-format': {
\ 'function': 'ale#fixers#lua_format#Fix',
\ 'suggested_filetypes': ['lua'],
diff --git a/autoload/ale/fixers/htmlbeautifier.vim b/autoload/ale/fixers/htmlbeautifier.vim
new file mode 100644
index 00000000..756d4a05
--- /dev/null
+++ b/autoload/ale/fixers/htmlbeautifier.vim
@@ -0,0 +1,13 @@
+" Author: Arash Mousavi <arash-m>
+" Description: Support for HTML Beautifier https://github.com/threedaymonk/htmlbeautifier
+
+call ale#Set('eruby_htmlbeautifier_executable', 'htmlbeautifier')
+
+function! ale#fixers#htmlbeautifier#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'eruby_htmlbeautifier_executable')
+
+ return {
+ \ 'command': ale#Escape(l:executable) . ' %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/doc/ale-eruby.txt b/doc/ale-eruby.txt
index 65bd8a30..82fe685a 100644
--- a/doc/ale-eruby.txt
+++ b/doc/ale-eruby.txt
@@ -7,6 +7,7 @@ There are four linters for `eruby` files:
- `erblint`
- `erubis`
- `erubi`
+- `htmlbeautifier`
- `ruumba`
`erb` is in the Ruby standard library and is mostly universal. `erubis` is the
@@ -48,6 +49,18 @@ g:ale_eruby_erblint_options *g:ale_ruby_erblint_options*
===============================================================================
+htmlbeautifier *ale-eruby-htmlbeautifier*
+
+g:ale_eruby_htmlbeautifier_executable *g:ale_eruby_htmlbeautifier_executable*
+ *b:ale_eruby_htmlbeautifier_executable*
+ Type: |String|
+ Default: `'htmlbeautifier'`
+
+ Override the invoked htmlbeautifier binary. This is useful for running
+ htmlbeautifier from binstubs or a bundle.
+
+
+===============================================================================
ruumba *ale-eruby-ruumba*
g:ale_eruby_ruumba_executable *g:ale_eruby_ruumba_executable*
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index d92321b4..2e4b4ab0 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -182,6 +182,7 @@ Notes:
* `erblint`
* `erubi`
* `erubis`
+ * `htmlbeautifier`
* `ruumba`
* Erlang
* `SyntaxErl`
diff --git a/doc/ale.txt b/doc/ale.txt
index 5cf92624..9f5d4f86 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -3020,6 +3020,7 @@ documented in additional help files.
eruby...................................|ale-eruby-options|
erb-formatter.........................|ale-eruby-erbformatter|
erblint...............................|ale-eruby-erblint|
+ htmlbeautifier........................|ale-eruby-htmlbeautifier|
ruumba................................|ale-eruby-ruumba|
fish....................................|ale-fish-options|
fish_indent...........................|ale-fish-fish_indent|
diff --git a/supported-tools.md b/supported-tools.md
index affdeff9..0b6383f5 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -191,6 +191,7 @@ formatting.
* [erblint](https://github.com/Shopify/erb-lint)
* [erubi](https://github.com/jeremyevans/erubi)
* [erubis](https://github.com/kwatch/erubis)
+ * [htmlbeautifier](https://github.com/threedaymonk/htmlbeautifier)
* [ruumba](https://github.com/ericqweinstein/ruumba)
* Erlang
* [SyntaxErl](https://github.com/ten0s/syntaxerl)
diff --git a/test/fixers/test_htmlbeautifier_fixer_callback.vader b/test/fixers/test_htmlbeautifier_fixer_callback.vader
new file mode 100644
index 00000000..e54bab97
--- /dev/null
+++ b/test/fixers/test_htmlbeautifier_fixer_callback.vader
@@ -0,0 +1,19 @@
+Before:
+ call ale#assert#SetUpFixerTest('eruby', 'htmlbeautifier')
+
+After:
+ call ale#assert#TearDownFixerTest()
+
+Execute(The htmlbeautifier callback should return the correct default values):
+ AssertFixer {
+ \ 'command': ale#Escape('htmlbeautifier') . ' %t',
+ \ 'read_temporary_file': 1,
+ \}
+
+Execute(The htmlbeautifier callback should allow custom htmlbeautifier executables):
+ let g:ale_eruby_htmlbeautifier_executable = 'foo/bar'
+
+ AssertFixer {
+ \ 'command': ale#Escape('foo/bar') . ' %t',
+ \ 'read_temporary_file': 1,
+ \}