From 6c0996eb9c3181c8dde1302b544787be758cc37b Mon Sep 17 00:00:00 2001 From: diartyz Date: Thu, 22 Dec 2016 19:39:01 +0800 Subject: [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 --- ale_linters/scss/stylelint.vim | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'ale_linters/scss') diff --git a/ale_linters/scss/stylelint.vim b/ale_linters/scss/stylelint.vim index 135fb8e7..2f5da7c9 100644 --- a/ale_linters/scss/stylelint.vim +++ b/ale_linters/scss/stylelint.vim @@ -1,8 +1,31 @@ " Author: diartyz +let g:ale_scss_stylelint_executable = +\ get(g:, 'ale_scss_stylelint_executable', 'stylelint') + +let g:ale_scss_stylelint_use_global = +\ get(g:, 'ale_scss_stylelint_use_global', 0) + +function! ale_linters#scss#stylelint#GetExecutable(buffer) abort + if g:ale_scss_stylelint_use_global + return g:ale_scss_stylelint_executable + endif + + return ale#util#ResolveLocalPath( + \ a:buffer, + \ 'node_modules/.bin/stylelint', + \ g:ale_scss_stylelint_executable + \) +endfunction + +function! ale_linters#scss#stylelint#GetCommand(buffer) abort + return ale_linters#scss#stylelint#GetExecutable(a:buffer) + \ . ' --stdin-filename %s' +endfunction + call ale#linter#Define('scss', { \ 'name': 'stylelint', -\ 'executable': 'stylelint', -\ 'command': g:ale#util#stdin_wrapper . ' .scss stylelint', +\ 'executable_callback': 'ale_linters#scss#stylelint#GetExecutable', +\ 'command_callback': 'ale_linters#scss#stylelint#GetCommand', \ 'callback': 'ale#handlers#HandleStyleLintFormat', \}) -- cgit v1.2.3