summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorAbin Simon <abinsimon10@gmail.com>2018-06-23 15:40:28 +0530
committerAbin Simon <abinsimon10@gmail.com>2018-06-23 22:59:13 +0530
commit17c1aefb5bdd58ff854f17e00aa949e841560e94 (patch)
treef79622a2cedd178cf4c7e749dfddd7cbd4137e4a /autoload
parent935740cf9310f52c60a67b33cfcd74f0140d95b8 (diff)
downloadale-17c1aefb5bdd58ff854f17e00aa949e841560e94.zip
Add fixer tidy for HTML
Add tests for tidy HTML fixer
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/tidy.vim26
2 files changed, 31 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index dec762a2..60d7d7a8 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -22,6 +22,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['python'],
\ 'description': 'Fix PEP8 issues with black.',
\ },
+\ 'tidy': {
+\ 'function': 'ale#fixers#tidy#Fix',
+\ 'suggested_filetypes': ['html'],
+\ 'description': 'Fix HTML files with tidy.',
+\ },
\ 'prettier_standard': {
\ 'function': 'ale#fixers#prettier_standard#Fix',
\ 'suggested_filetypes': ['javascript'],
diff --git a/autoload/ale/fixers/tidy.vim b/autoload/ale/fixers/tidy.vim
new file mode 100644
index 00000000..1af4120b
--- /dev/null
+++ b/autoload/ale/fixers/tidy.vim
@@ -0,0 +1,26 @@
+" Author: meain <abinsimon10@gmail.com>
+" Description: Fixing HTML files with tidy.
+
+call ale#Set('html_tidy_executable', 'tidy')
+call ale#Set('html_tidy_use_global', get(g:, 'ale_use_global_executables', 0))
+
+function! ale#fixers#tidy#Fix(buffer) abort
+ let l:executable = ale#node#FindExecutable(
+ \ a:buffer,
+ \ 'html_tidy',
+ \ ['tidy'],
+ \)
+
+ if !executable(l:executable)
+ return 0
+ endif
+
+ let l:config = ale#path#FindNearestFile(a:buffer, '.tidyrc')
+ let l:config_options = !empty(l:config)
+ \ ? ' -q --tidy-mark no --show-errors 0 --show-warnings 0 -config ' . ale#Escape(l:config)
+ \ : ' -q --tidy-mark no --show-errors 0 --show-warnings 0'
+
+ return {
+ \ 'command': ale#Escape(l:executable) . l:config_options,
+ \}
+endfunction