Add support for html-beautify (#2788)
* Add support for html-beautify * Add html-beautify to the list of supported tools * Update docs
This commit is contained in:
parent
af8c8516d1
commit
47eb3dd0c0
8 changed files with 69 additions and 0 deletions
|
@ -350,6 +350,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['nix'],
|
\ 'suggested_filetypes': ['nix'],
|
||||||
\ 'description': 'A formatter for Nix code',
|
\ 'description': 'A formatter for Nix code',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'html-beautify': {
|
||||||
|
\ 'function': 'ale#fixers#html_beautify#Fix',
|
||||||
|
\ 'suggested_filetypes': ['html', 'htmldjango'],
|
||||||
|
\ 'description': 'Fix HTML files with html-beautify.',
|
||||||
|
\ },
|
||||||
\}
|
\}
|
||||||
|
|
||||||
" Reset the function registry to the default entries.
|
" Reset the function registry to the default entries.
|
||||||
|
|
21
autoload/ale/fixers/html_beautify.vim
Normal file
21
autoload/ale/fixers/html_beautify.vim
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
" Author: WhyNotHugo <hugo@barrera.io>
|
||||||
|
" Description: Lint HTML files with html-beautify.
|
||||||
|
"
|
||||||
|
call ale#Set('html_beautify_executable', 'html-beautify')
|
||||||
|
call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||||
|
call ale#Set('html_beautify_options', '')
|
||||||
|
call ale#Set('html_beautify_change_directory', 1)
|
||||||
|
|
||||||
|
function! ale#fixers#html_beautify#Fix(buffer) abort
|
||||||
|
let l:executable = ale#python#FindExecutable(
|
||||||
|
\ a:buffer,
|
||||||
|
\ 'html_beautify',
|
||||||
|
\ ['html-beautify']
|
||||||
|
\)
|
||||||
|
|
||||||
|
let l:options = ale#Var(a:buffer, 'html_beautify_options')
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable). ' ' . l:options . ' -',
|
||||||
|
\}
|
||||||
|
endfunction
|
|
@ -9,6 +9,16 @@ fecs *ale-html-fecs*
|
||||||
and both of them reads `./.fecsrc` as the default configuration file.
|
and both of them reads `./.fecsrc` as the default configuration file.
|
||||||
See: |ale-javascript-fecs|.
|
See: |ale-javascript-fecs|.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
html-beautify *ale-html-beautify*
|
||||||
|
|
||||||
|
g:ale_html_beautify_options *g:ale_html_beautify_options*
|
||||||
|
*b:ale_html_beautify_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be changed to modify flags given to html-beautify.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
htmlhint *ale-html-htmlhint*
|
htmlhint *ale-html-htmlhint*
|
||||||
|
|
|
@ -2293,6 +2293,7 @@ documented in additional help files.
|
||||||
terraform-fmt.........................|ale-hcl-terraform-fmt|
|
terraform-fmt.........................|ale-hcl-terraform-fmt|
|
||||||
html....................................|ale-html-options|
|
html....................................|ale-html-options|
|
||||||
fecs..................................|ale-html-fecs|
|
fecs..................................|ale-html-fecs|
|
||||||
|
html-beautify.........................|ale-html-beautify|
|
||||||
htmlhint..............................|ale-html-htmlhint|
|
htmlhint..............................|ale-html-htmlhint|
|
||||||
tidy..................................|ale-html-tidy|
|
tidy..................................|ale-html-tidy|
|
||||||
prettier..............................|ale-html-prettier|
|
prettier..............................|ale-html-prettier|
|
||||||
|
|
|
@ -203,6 +203,7 @@ formatting.
|
||||||
* HTML
|
* HTML
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
||||||
* [fecs](http://fecs.baidu.com/)
|
* [fecs](http://fecs.baidu.com/)
|
||||||
|
* [html-beautify](https://beautifier.io/)
|
||||||
* [HTMLHint](http://htmlhint.com/)
|
* [HTMLHint](http://htmlhint.com/)
|
||||||
* [prettier](https://github.com/prettier/prettier)
|
* [prettier](https://github.com/prettier/prettier)
|
||||||
* [proselint](http://proselint.com/)
|
* [proselint](http://proselint.com/)
|
||||||
|
|
0
test/command_callback/html_beautify_paths/html-beautify
Executable file
0
test/command_callback/html_beautify_paths/html-beautify
Executable file
0
test/command_callback/html_beautify_paths/test.html
Normal file
0
test/command_callback/html_beautify_paths/test.html
Normal file
31
test/fixers/test_html_beautify_fixer_callback.vader
Normal file
31
test/fixers/test_html_beautify_fixer_callback.vader
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
Before:
|
||||||
|
Save g:ale_html_beautify_executable
|
||||||
|
Save g:ale_html_beautify_options
|
||||||
|
|
||||||
|
let g:ale_html_beautify_options = ''
|
||||||
|
|
||||||
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
silent cd ..
|
||||||
|
silent cd command_callback
|
||||||
|
let g:dir = getcwd()
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
unlet! b:bin_dir
|
||||||
|
|
||||||
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
|
Execute(The html-beautify callback should return 0 if html-beautify not found):
|
||||||
|
let g:ale_html_beautify_executable = 'xxxinvalidpath'
|
||||||
|
AssertEqual
|
||||||
|
\ 0,
|
||||||
|
\ ale#fixers#html_beautify#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The html-beautify callback should return the correct default command):
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('html_beautify_paths/html-beautify')
|
||||||
|
\ . ' -'
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#html_beautify#Fix(bufnr(''))
|
Reference in a new issue