diff options
-rw-r--r-- | autoload/ale/fix/registry.vim | 7 | ||||
-rw-r--r-- | autoload/ale/fixers/css_beautify.vim | 20 | ||||
-rw-r--r-- | autoload/ale/fixers/html_beautify.vim | 7 | ||||
-rw-r--r-- | doc/ale-css.txt | 27 | ||||
-rw-r--r-- | doc/ale-html.txt | 17 | ||||
-rw-r--r-- | doc/ale-supported-languages-and-tools.txt | 1 | ||||
-rw-r--r-- | doc/ale.txt | 1 | ||||
-rw-r--r-- | supported-tools.md | 1 | ||||
-rw-r--r-- | test/fixers/test_css_beautify_fixer_callback.vader | 12 |
9 files changed, 87 insertions, 6 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 78dad32e..f058123e 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -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', diff --git a/autoload/ale/fixers/css_beautify.vim b/autoload/ale/fixers/css_beautify.vim new file mode 100644 index 00000000..14a837c4 --- /dev/null +++ b/autoload/ale/fixers/css_beautify.vim @@ -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 diff --git a/autoload/ale/fixers/html_beautify.vim b/autoload/ale/fixers/html_beautify.vim index 236cb6ec..9817563e 100644 --- a/autoload/ale/fixers/html_beautify.vim +++ b/autoload/ale/fixers/html_beautify.vim @@ -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 diff --git a/doc/ale-css.txt b/doc/ale-css.txt index f5c240e8..74ca16dd 100644 --- a/doc/ale-css.txt +++ b/doc/ale-css.txt @@ -9,6 +9,33 @@ 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` options for CSS is the same as the options for JavaScript, and both of diff --git a/doc/ale-html.txt b/doc/ale-html.txt index d945acdf..6d18afd1 100644 --- a/doc/ale-html.txt +++ b/doc/ale-html.txt @@ -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* diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 080b7ec0..e0a2d557 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -120,6 +120,7 @@ Notes: * CSS * `VSCode CSS language server` * `cspell` + * `css-beautify` * `csslint` * `fecs` * `prettier` diff --git a/doc/ale.txt b/doc/ale.txt index c20924be..c4ffcf8d 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -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| diff --git a/supported-tools.md b/supported-tools.md index 64f3cce3..a835ac2f 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -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) diff --git a/test/fixers/test_css_beautify_fixer_callback.vader b/test/fixers/test_css_beautify_fixer_callback.vader new file mode 100644 index 00000000..a6b61713 --- /dev/null +++ b/test/fixers/test_css_beautify_fixer_callback.vader @@ -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('')) |