mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 20:54:26 +08:00
Add fixer "css-beautify". Adjust "html-beautify." (#4319)
* Add fixer "css-beautify". Adjust "html-beautify." * Error fixes. * Added chars.
This commit is contained in:
committed by
GitHub
parent
7dd13afc6c
commit
a33960eb51
@@ -47,6 +47,11 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['bzl'],
|
\ 'suggested_filetypes': ['bzl'],
|
||||||
\ 'description': 'Format BUILD and .bzl files with buildifier.',
|
\ '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': {
|
\ 'deno': {
|
||||||
\ 'function': 'ale#fixers#deno#Fix',
|
\ 'function': 'ale#fixers#deno#Fix',
|
||||||
\ 'suggested_filetypes': ['typescript'],
|
\ 'suggested_filetypes': ['typescript'],
|
||||||
@@ -514,7 +519,7 @@ let s:default_registry = {
|
|||||||
\ 'html-beautify': {
|
\ 'html-beautify': {
|
||||||
\ 'function': 'ale#fixers#html_beautify#Fix',
|
\ 'function': 'ale#fixers#html_beautify#Fix',
|
||||||
\ 'suggested_filetypes': ['html', 'htmldjango'],
|
\ 'suggested_filetypes': ['html', 'htmldjango'],
|
||||||
\ 'description': 'Fix HTML files with html-beautify.',
|
\ 'description': 'Fix HTML files with html-beautify from js-beautify.',
|
||||||
\ },
|
\ },
|
||||||
\ 'lua-format': {
|
\ 'lua-format': {
|
||||||
\ 'function': 'ale#fixers#lua_format#Fix',
|
\ 'function': 'ale#fixers#lua_format#Fix',
|
||||||
|
|||||||
20
autoload/ale/fixers/css_beautify.vim
Normal file
20
autoload/ale/fixers/css_beautify.vim
Normal 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
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
" Author: WhyNotHugo <hugo@barrera.io>
|
" 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_executable', 'html-beautify')
|
||||||
call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0))
|
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_options', '')
|
||||||
call ale#Set('html_beautify_change_directory', 1)
|
|
||||||
|
|
||||||
function! ale#fixers#html_beautify#Fix(buffer) abort
|
function! ale#fixers#html_beautify#Fix(buffer) abort
|
||||||
let l:executable = ale#python#FindExecutable(
|
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')
|
let l:options = ale#Var(a:buffer, 'html_beautify_options')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
\ 'command': ale#Escape(l:executable). ' ' . l:options . ' -',
|
\ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -',
|
||||||
\}
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -8,6 +8,33 @@ cspell *ale-css-cspell*
|
|||||||
See |ale-cspell-options|
|
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*
|
fecs *ale-css-fecs*
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,14 @@ See: |ale-javascript-fecs|.
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
html-beautify *ale-html-beautify*
|
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*
|
g:ale_html_beautify_options *g:ale_html_beautify_options*
|
||||||
*b:ale_html_beautify_options*
|
*b:ale_html_beautify_options*
|
||||||
Type: |String|
|
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.
|
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*
|
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|
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
prettier *ale-html-prettier*
|
prettier *ale-html-prettier*
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ Notes:
|
|||||||
* CSS
|
* CSS
|
||||||
* `VSCode CSS language server`
|
* `VSCode CSS language server`
|
||||||
* `cspell`
|
* `cspell`
|
||||||
|
* `css-beautify`
|
||||||
* `csslint`
|
* `csslint`
|
||||||
* `fecs`
|
* `fecs`
|
||||||
* `prettier`
|
* `prettier`
|
||||||
|
|||||||
@@ -2841,6 +2841,7 @@ documented in additional help files.
|
|||||||
uncrustify............................|ale-cs-uncrustify|
|
uncrustify............................|ale-cs-uncrustify|
|
||||||
css.....................................|ale-css-options|
|
css.....................................|ale-css-options|
|
||||||
cspell................................|ale-css-cspell|
|
cspell................................|ale-css-cspell|
|
||||||
|
css-beautify..........................|ale-css-css-beautify|
|
||||||
fecs..................................|ale-css-fecs|
|
fecs..................................|ale-css-fecs|
|
||||||
prettier..............................|ale-css-prettier|
|
prettier..............................|ale-css-prettier|
|
||||||
stylelint.............................|ale-css-stylelint|
|
stylelint.............................|ale-css-stylelint|
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ formatting.
|
|||||||
* CSS
|
* CSS
|
||||||
* [VSCode CSS language server](https://github.com/hrsh7th/vscode-langservers-extracted)
|
* [VSCode CSS language server](https://github.com/hrsh7th/vscode-langservers-extracted)
|
||||||
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
|
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
|
||||||
|
* [css-beautify](https://github.com/beautify-web/js-beautify)
|
||||||
* [csslint](http://csslint.net/)
|
* [csslint](http://csslint.net/)
|
||||||
* [fecs](http://fecs.baidu.com/)
|
* [fecs](http://fecs.baidu.com/)
|
||||||
* [prettier](https://github.com/prettier/prettier)
|
* [prettier](https://github.com/prettier/prettier)
|
||||||
|
|||||||
12
test/fixers/test_css_beautify_fixer_callback.vader
Normal file
12
test/fixers/test_css_beautify_fixer_callback.vader
Normal 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(''))
|
||||||
Reference in New Issue
Block a user