summaryrefslogtreecommitdiff
path: root/ale_linters/html
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/html')
-rw-r--r--ale_linters/html/htmlhint.vim31
-rw-r--r--ale_linters/html/tidy.vim11
-rw-r--r--ale_linters/html/write-good.vim9
-rw-r--r--ale_linters/html/writegood.vim4
4 files changed, 25 insertions, 30 deletions
diff --git a/ale_linters/html/htmlhint.vim b/ale_linters/html/htmlhint.vim
index e142d22a..234c1176 100644
--- a/ale_linters/html/htmlhint.vim
+++ b/ale_linters/html/htmlhint.vim
@@ -1,25 +1,32 @@
" Author: KabbAmine <amine.kabb@gmail.com>, deathmaz <00maz1987@gmail.com>, diartyz <diartyz@gmail.com>
" Description: HTMLHint for checking html files
-call ale#Set('html_htmlhint_options', '--format=unix')
+call ale#Set('html_htmlhint_options', '')
call ale#Set('html_htmlhint_executable', 'htmlhint')
-call ale#Set('html_htmlhint_use_global', 0)
-
-function! ale_linters#html#htmlhint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'html_htmlhint', [
- \ 'node_modules/.bin/htmlhint',
- \])
-endfunction
+call ale#Set('html_htmlhint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#html#htmlhint#GetCommand(buffer) abort
- return ale_linters#html#htmlhint#GetExecutable(a:buffer)
- \ . ' ' . ale#Var(a:buffer, 'html_htmlhint_options')
- \ . ' %t'
+ let l:options = ale#Var(a:buffer, 'html_htmlhint_options')
+ let l:config = l:options !~# '--config'
+ \ ? ale#path#FindNearestFile(a:buffer, '.htmlhintrc')
+ \ : ''
+
+ if !empty(l:config)
+ let l:options .= ' --config ' . ale#Escape(l:config)
+ endif
+
+ if !empty(l:options)
+ let l:options = substitute(l:options, '--format=unix', '', '')
+ endif
+
+ return '%e' . ale#Pad(l:options) . ' --format=unix %t'
endfunction
call ale#linter#Define('html', {
\ 'name': 'htmlhint',
-\ 'executable_callback': 'ale_linters#html#htmlhint#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('html_htmlhint', [
+\ 'node_modules/.bin/htmlhint',
+\ ]),
\ 'command_callback': 'ale_linters#html#htmlhint#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsError',
\})
diff --git a/ale_linters/html/tidy.vim b/ale_linters/html/tidy.vim
index 34152c6b..cab8bc24 100644
--- a/ale_linters/html/tidy.vim
+++ b/ale_linters/html/tidy.vim
@@ -1,11 +1,8 @@
" Author: KabbAmine <amine.kabb@gmail.com>
" Description: This file adds support for checking HTML code with tidy.
-" CLI options
let g:ale_html_tidy_executable = get(g:, 'ale_html_tidy_executable', 'tidy')
-" Look for the old _args variable first.
-let s:default_options = get(g:, 'ale_html_tidy_args', '-q -e -language en')
-let g:ale_html_tidy_options = get(g:, 'ale_html_tidy_options', s:default_options)
+let g:ale_html_tidy_options = get(g:, 'ale_html_tidy_options', '-q -e -language en')
function! ale_linters#html#tidy#GetCommand(buffer) abort
" Specify file encoding in options
@@ -40,10 +37,6 @@ function! ale_linters#html#tidy#GetCommand(buffer) abort
\)
endfunction
-function! ale_linters#html#tidy#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'html_tidy_executable')
-endfunction
-
function! ale_linters#html#tidy#Handle(buffer, lines) abort
" Matches patterns lines like the following:
" line 7 column 5 - Warning: missing </title> before </head>
@@ -70,7 +63,7 @@ endfunction
call ale#linter#Define('html', {
\ 'name': 'tidy',
-\ 'executable_callback': 'ale_linters#html#tidy#GetExecutable',
+\ 'executable_callback': ale#VarFunc('html_tidy_executable'),
\ 'output_stream': 'stderr',
\ 'command_callback': 'ale_linters#html#tidy#GetCommand',
\ 'callback': 'ale_linters#html#tidy#Handle',
diff --git a/ale_linters/html/write-good.vim b/ale_linters/html/write-good.vim
deleted file mode 100644
index 9fae8821..00000000
--- a/ale_linters/html/write-good.vim
+++ /dev/null
@@ -1,9 +0,0 @@
-" Author: Sumner Evans <sumner.evans98@gmail.com>
-" Description: write-good for nroff files
-
-call ale#linter#Define('html', {
-\ 'name': 'write-good',
-\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
-\ 'command_callback': 'ale#handlers#writegood#GetCommand',
-\ 'callback': 'ale#handlers#writegood#Handle',
-\})
diff --git a/ale_linters/html/writegood.vim b/ale_linters/html/writegood.vim
new file mode 100644
index 00000000..6a2bd8e5
--- /dev/null
+++ b/ale_linters/html/writegood.vim
@@ -0,0 +1,4 @@
+" Author: Sumner Evans <sumner.evans98@gmail.com>
+" Description: write-good for html files
+
+call ale#handlers#writegood#DefineLinter('html')