Add htmlbeautifier support (#4751)

This commit is contained in:
Arash Mousavi 2024-04-17 15:58:28 +01:00 committed by GitHub
parent 6db58b3379
commit 7516e2e484
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 53 additions and 0 deletions

View File

@ -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'],

View File

@ -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

View File

@ -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
@ -47,6 +48,18 @@ g:ale_eruby_erblint_options *g:ale_ruby_erblint_options*
This variable can be change to modify flags given to erblint.
===============================================================================
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*

View File

@ -182,6 +182,7 @@ Notes:
* `erblint`
* `erubi`
* `erubis`
* `htmlbeautifier`
* `ruumba`
* Erlang
* `SyntaxErl`

View File

@ -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|

View File

@ -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)

View File

@ -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,
\}