summaryrefslogtreecommitdiff
path: root/ale_linters/css
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/css
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/css')
-rw-r--r--ale_linters/css/stylelint.vim27
1 files changed, 25 insertions, 2 deletions
diff --git a/ale_linters/css/stylelint.vim b/ale_linters/css/stylelint.vim
index 8d656651..e138d6d0 100644
--- a/ale_linters/css/stylelint.vim
+++ b/ale_linters/css/stylelint.vim
@@ -1,8 +1,31 @@
" Author: diartyz <diartyz@gmail.com>
+let g:ale_css_stylelint_executable =
+\ get(g:, 'ale_css_stylelint_executable', 'stylelint')
+
+let g:ale_css_stylelint_use_global =
+\ get(g:, 'ale_css_stylelint_use_global', 0)
+
+function! ale_linters#css#stylelint#GetExecutable(buffer) abort
+ if g:ale_css_stylelint_use_global
+ return g:ale_css_stylelint_executable
+ endif
+
+ return ale#util#ResolveLocalPath(
+ \ a:buffer,
+ \ 'node_modules/.bin/stylelint',
+ \ g:ale_css_stylelint_executable
+ \)
+endfunction
+
+function! ale_linters#css#stylelint#GetCommand(buffer) abort
+ return ale_linters#css#stylelint#GetExecutable(a:buffer)
+ \ . ' --stdin-filename %s'
+endfunction
+
call ale#linter#Define('css', {
\ 'name': 'stylelint',
-\ 'executable': 'stylelint',
-\ 'command': g:ale#util#stdin_wrapper . ' .css stylelint',
+\ 'executable_callback': 'ale_linters#css#stylelint#GetExecutable',
+\ 'command_callback': 'ale_linters#css#stylelint#GetCommand',
\ 'callback': 'ale#handlers#HandleStyleLintFormat',
\})