summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo R. Roig Carralero <groig@users.noreply.github.com>2023-03-26 06:38:24 +0000
committerGitHub <noreply@github.com>2023-03-26 15:38:24 +0900
commit7dbd3c96ac1eb3a1981e740423a31500108f6e25 (patch)
tree83f578aa588edbf7f29c4819e52a940515004441
parentfbae1bc1937ce69fa80b4b32d178ce666fd5c07c (diff)
downloadale-7dbd3c96ac1eb3a1981e740423a31500108f6e25.zip
Add support for `rustywind` fixer (#4477)
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/rustywind.vim17
-rw-r--r--doc/ale-html.txt19
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/fixers/test_rustywind_fixer_callback.vader36
-rw-r--r--test/test-files/rustywind/test.html0
8 files changed, 80 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index b3275a32..f7fff6a7 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -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',
\ }
\}
diff --git a/autoload/ale/fixers/rustywind.vim b/autoload/ale/fixers/rustywind.vim
new file mode 100644
index 00000000..5e9bb3c5
--- /dev/null
+++ b/autoload/ale/fixers/rustywind.vim
@@ -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
diff --git a/doc/ale-html.txt b/doc/ale-html.txt
index 6d18afd1..189a7ed0 100644
--- a/doc/ale-html.txt
+++ b/doc/ale-html.txt
@@ -103,6 +103,25 @@ 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*
g:ale_html_stylelint_executable *g:ale_html_stylelint_executable*
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index 60b2537e..d56d0a76 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -262,6 +262,7 @@ Notes:
* `htmlhint`
* `prettier`
* `proselint`
+ * `rustywind`
* `tidy`
* `write-good`
* Idris
diff --git a/doc/ale.txt b/doc/ale.txt
index 60fcb05a..e7d9f9be 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -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|
diff --git a/supported-tools.md b/supported-tools.md
index 722bff88..0767cc35 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -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
diff --git a/test/fixers/test_rustywind_fixer_callback.vader b/test/fixers/test_rustywind_fixer_callback.vader
new file mode 100644
index 00000000..45364752
--- /dev/null
+++ b/test/fixers/test_rustywind_fixer_callback.vader
@@ -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(''))
diff --git a/test/test-files/rustywind/test.html b/test/test-files/rustywind/test.html
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/test-files/rustywind/test.html