summaryrefslogtreecommitdiff
path: root/ale_linters/html
diff options
context:
space:
mode:
authordiartyz <diartyz@gmail.com>2016-12-22 19:39:01 +0800
committerw0rp <w0rp@users.noreply.github.com>2016-12-22 11:39:01 +0000
commit6c0996eb9c3181c8dde1302b544787be758cc37b (patch)
tree0a9ffc481e59c3c1fa34aec414a40441ef29fd64 /ale_linters/html
parentcd6d8f2ab62e30571da9384c561da03b36f60b1c (diff)
downloadale-6c0996eb9c3181c8dde1302b544787be758cc37b.zip
[enhancement] add node_modules support for stylelint & htmlhint (#226)
* Add node_modules support for stylelint * add node_modules support for htmlhint * fix stdin * update doc about stylelint & htmlhint
Diffstat (limited to 'ale_linters/html')
-rw-r--r--ale_linters/html/htmlhint.vim30
1 files changed, 27 insertions, 3 deletions
diff --git a/ale_linters/html/htmlhint.vim b/ale_linters/html/htmlhint.vim
index 59c2ed20..910f3e63 100644
--- a/ale_linters/html/htmlhint.vim
+++ b/ale_linters/html/htmlhint.vim
@@ -1,12 +1,36 @@
-" Author: KabbAmine <amine.kabb@gmail.com>, deathmaz <00maz1987@gmail.com>
+" Author: KabbAmine <amine.kabb@gmail.com>, deathmaz <00maz1987@gmail.com>, diartyz <diartyz@gmail.com>
" Description: HTMLHint for checking html files
" CLI options
let g:ale_html_htmlhint_options = get(g:, 'ale_html_htmlhint_options', '--format=unix')
+let g:ale_html_htmlhint_executable =
+\ get(g:, 'ale_html_htmlhint_executable', 'htmlhint')
+
+let g:ale_html_htmlhint_use_global =
+\ get(g:, 'ale_html_htmlhint_use_global', 0)
+
+function! ale_linters#html#htmlhint#GetExecutable(buffer) abort
+ if g:ale_html_htmlhint_use_global
+ return g:ale_html_htmlhint_executable
+ endif
+
+ return ale#util#ResolveLocalPath(
+ \ a:buffer,
+ \ 'node_modules/.bin/htmlhint',
+ \ g:ale_html_htmlhint_executable
+ \)
+endfunction
+
+function! ale_linters#html#htmlhint#GetCommand(buffer) abort
+ return g:ale#util#stdin_wrapper . ' .html '
+ \ . ale_linters#html#htmlhint#GetExecutable(a:buffer)
+ \ . ' ' . g:ale_html_htmlhint_options
+endfunction
+
call ale#linter#Define('html', {
\ 'name': 'htmlhint',
-\ 'executable': 'htmlhint',
-\ 'command': 'htmlhint ' . g:ale_html_htmlhint_options . ' stdin',
+\ 'executable_callback': 'ale_linters#html#htmlhint#GetExecutable',
+\ 'command_callback': 'ale_linters#html#htmlhint#GetCommand',
\ 'callback': 'ale#handlers#HandleUnixFormatAsError',
\})