Add fixer "css-beautify". Adjust "html-beautify." (#4319)

* Add fixer "css-beautify". Adjust "html-beautify."

* Error fixes.

* Added chars.
This commit is contained in:
Matheus Gabriel Werny de Lima 2022-09-30 12:24:32 +02:00 committed by GitHub
parent 7dd13afc6c
commit a33960eb51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 87 additions and 6 deletions

View File

@ -47,6 +47,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['bzl'],
\ 'description': 'Format BUILD and .bzl files with buildifier.',
\ },
\ 'css-beautify': {
\ 'function': 'ale#fixers#css_beautify#Fix',
\ 'suggested_filetypes': ['css'],
\ 'description': 'Format CSS using css-beautify from js-beautify.',
\ },
\ 'deno': {
\ 'function': 'ale#fixers#deno#Fix',
\ 'suggested_filetypes': ['typescript'],
@ -514,7 +519,7 @@ let s:default_registry = {
\ 'html-beautify': {
\ 'function': 'ale#fixers#html_beautify#Fix',
\ 'suggested_filetypes': ['html', 'htmldjango'],
\ 'description': 'Fix HTML files with html-beautify.',
\ 'description': 'Fix HTML files with html-beautify from js-beautify.',
\ },
\ 'lua-format': {
\ 'function': 'ale#fixers#lua_format#Fix',

View File

@ -0,0 +1,20 @@
" Author: https://github.com/Spixmaster
" Description: Format CSS using css-beautify from js-beautify.
call ale#Set('css_css_beautify_executable', 'css-beautify')
call ale#Set('css_css_beautify_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('css_css_beautify_options', '')
function! ale#fixers#css_beautify#Fix(buffer) abort
let l:executable = ale#python#FindExecutable(
\ a:buffer,
\ 'css_css_beautify',
\ ['css-beautify']
\)
let l:options = ale#Var(a:buffer, 'css_css_beautify_options')
return {
\ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -',
\}
endfunction

View File

@ -1,10 +1,9 @@
" Author: WhyNotHugo <hugo@barrera.io>
" Description: Lint HTML files with html-beautify.
"
" Description: Format 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(
@ -16,6 +15,6 @@ function! ale#fixers#html_beautify#Fix(buffer) abort
let l:options = ale#Var(a:buffer, 'html_beautify_options')
return {
\ 'command': ale#Escape(l:executable). ' ' . l:options . ' -',
\ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -',
\}
endfunction

View File

@ -8,6 +8,33 @@ cspell *ale-css-cspell*
See |ale-cspell-options|
===============================================================================
css-beautify *ale-css-css-beautify*
g:ale_css_css_beautify_executable *g:ale_css_css_beautify_executable*
*b:ale_css_css_beautify_executable*
Type: |String|
Default: `'css-beautify'`
See |ale-integrations-local-executables|
g:ale_css_css_beautify_options *g:ale_css_css_beautify_options*
*b:ale_css_css_beautify_options*
Type: |String|
Default: `''`
This variable can be set to pass additional options to css-beautify.
g:ale_css_css_beautify_use_global *g:ale_css_css_beautify_use_global*
*b:ale_css_css_beautify_use_global*
Type: |String|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
fecs *ale-css-fecs*

View File

@ -45,6 +45,14 @@ See: |ale-javascript-fecs|.
===============================================================================
html-beautify *ale-html-beautify*
g:ale_html_beautify_executable *g:ale_html_beautify_executable*
*b:ale_html_beautify_executable*
Type: |String|
Default: `'html-beautify'`
See |ale-integrations-local-executables|
g:ale_html_beautify_options *g:ale_html_beautify_options*
*b:ale_html_beautify_options*
Type: |String|
@ -53,6 +61,14 @@ g:ale_html_beautify_options *g:ale_html_beautify_options*
This variable can be changed to modify flags given to html-beautify.
g:ale_html_beautify_use_global *g:ale_html_beautify_use_global*
*b:ale_html_beautify_use_global*
Type: |String|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
htmlhint *ale-html-htmlhint*
@ -80,7 +96,6 @@ g:ale_html_htmlhint_use_global *g:ale_html_htmlhint_use_global*
See |ale-integrations-local-executables|
===============================================================================
prettier *ale-html-prettier*

View File

@ -120,6 +120,7 @@ Notes:
* CSS
* `VSCode CSS language server`
* `cspell`
* `css-beautify`
* `csslint`
* `fecs`
* `prettier`

View File

@ -2841,6 +2841,7 @@ documented in additional help files.
uncrustify............................|ale-cs-uncrustify|
css.....................................|ale-css-options|
cspell................................|ale-css-cspell|
css-beautify..........................|ale-css-css-beautify|
fecs..................................|ale-css-fecs|
prettier..............................|ale-css-prettier|
stylelint.............................|ale-css-stylelint|

View File

@ -129,6 +129,7 @@ formatting.
* CSS
* [VSCode CSS language server](https://github.com/hrsh7th/vscode-langservers-extracted)
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
* [css-beautify](https://github.com/beautify-web/js-beautify)
* [csslint](http://csslint.net/)
* [fecs](http://fecs.baidu.com/)
* [prettier](https://github.com/prettier/prettier)

View File

@ -0,0 +1,12 @@
Before:
call ale#assert#SetUpFixerTest('css', 'css-beautify', 'beautify')
After:
Restore
call ale#assert#TearDownFixerTest()
Execute(The css-beautify callback should return the correct default command):
AssertEqual
\ {'command': ale#Escape('css-beautify') . ' -'},
\ ale#fixers#css_beautify#Fix(bufnr(''))