summaryrefslogtreecommitdiff
path: root/ale_linters/html
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-01-28 12:44:42 +0000
committerw0rp <devw0rp@gmail.com>2018-01-28 12:44:42 +0000
commit65fc5d11c77527bbf19a94da919fb37b5a02924b (patch)
tree4bbd896f3b6032732682e4840d326768fc9db8ea /ale_linters/html
parent7ef55a86152c3e17e13702f0d9753d7fc9c4d256 (diff)
downloadale-65fc5d11c77527bbf19a94da919fb37b5a02924b.zip
Fix #1038 - Automatically detect and use htmlhint configuration files
Diffstat (limited to 'ale_linters/html')
-rw-r--r--ale_linters/html/htmlhint.vim21
1 files changed, 17 insertions, 4 deletions
diff --git a/ale_linters/html/htmlhint.vim b/ale_linters/html/htmlhint.vim
index e142d22a..88a83f1d 100644
--- a/ale_linters/html/htmlhint.vim
+++ b/ale_linters/html/htmlhint.vim
@@ -1,7 +1,7 @@
" 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)
@@ -12,9 +12,22 @@ function! ale_linters#html#htmlhint#GetExecutable(buffer) abort
endfunction
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 ale#Escape(ale_linters#html#htmlhint#GetExecutable(a:buffer))
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' --format=unix %t'
endfunction
call ale#linter#Define('html', {