Add support for `rustywind` fixer (#4477)

This commit is contained in:
Guillermo R. Roig Carralero 2023-03-26 06:38:24 +00:00 committed by GitHub
parent fbae1bc193
commit 7dbd3c96ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 80 additions and 0 deletions

View File

@ -600,6 +600,11 @@ let s:default_registry = {
\ 'function': 'ale#fixers#pycln#Fix',
\ 'suggested_filetypes': ['python'],
\ 'description': 'remove unused python import statements',
\ },
\ 'rustywind': {
\ 'function': 'ale#fixers#rustywind#Fix',
\ 'suggested_filetypes': ['html'],
\ 'description': 'Sort Tailwind CSS classes',
\ }
\}

View File

@ -0,0 +1,17 @@
scriptencoding utf-8
" Author: Guillermo Roig <groig@protonmail.com>
" Description: Sort TailwindCSS classes with rustywind
call ale#Set('html_rustywind_executable', 'rustywind')
call ale#Set('html_rustywind_options', '')
function! ale#fixers#rustywind#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'html_rustywind_executable')
let l:options = ale#Var(a:buffer, 'html_rustywind_options')
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' --stdin'
\}
endfunction

View File

@ -102,6 +102,25 @@ prettier *ale-html-prettier*
See |ale-javascript-prettier| for information about the available options.
===============================================================================
rustywind *ale-html-rustywind*
g:ale_html_rustywind_executable *g:ale_html_rustywind_executable*
*b:ale_html_rustywind_executable*
Type: |String|
Default: `'rustywind'`
See |ale-integrations-local-executables|
g:ale_html_rustywind_options *g:ale_html_rustywind_options*
*b:ale_html_rustywind_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to rustywind.
===============================================================================
stylelint *ale-html-stylelint*

View File

@ -262,6 +262,7 @@ Notes:
* `htmlhint`
* `prettier`
* `proselint`
* `rustywind`
* `tidy`
* `write-good`
* Idris

View File

@ -2996,6 +2996,7 @@ documented in additional help files.
html-beautify.........................|ale-html-beautify|
htmlhint..............................|ale-html-htmlhint|
prettier..............................|ale-html-prettier|
rustywind.............................|ale-html-rustywind|
stylelint.............................|ale-html-stylelint|
tidy..................................|ale-html-tidy|
vscodehtml............................|ale-html-vscode|

View File

@ -271,6 +271,7 @@ formatting.
* [htmlhint](http://htmlhint.com/)
* [prettier](https://github.com/prettier/prettier)
* [proselint](http://proselint.com/)
* [rustywind](https://github.com/avencera/rustywind)
* [tidy](http://www.html-tidy.org/)
* [write-good](https://github.com/btford/write-good)
* Idris

View File

@ -0,0 +1,36 @@
Before:
Save g:ale_html_rustywind_executable
Save g:ale_html_rustywind_options
" Use an invalid global executable, so we don't match it.
let g:ale_html_rustywind_executable = 'xxxinvalid'
let g:ale_html_rustywind_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The rustywind callback should return the correct default values):
call ale#test#SetFilename('../test-files/rustywind/test.html')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' --stdin',
\ },
\ ale#fixers#rustywind#Fix(bufnr(''))
Execute(The rustywind callback should include custom rustywind options):
let g:ale_html_rustywind_options = "--custom-regex some-regex"
call ale#test#SetFilename('../test-files/rustywind/test.html')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_html_rustywind_options
\ . ' --stdin',
\ },
\ ale#fixers#rustywind#Fix(bufnr(''))

View File