diff options
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/css/stylelint.vim | 27 | ||||
-rw-r--r-- | ale_linters/html/htmlhint.vim | 30 | ||||
-rw-r--r-- | ale_linters/sass/stylelint.vim | 27 | ||||
-rw-r--r-- | ale_linters/scss/stylelint.vim | 27 |
4 files changed, 102 insertions, 9 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', \}) 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', \}) diff --git a/ale_linters/sass/stylelint.vim b/ale_linters/sass/stylelint.vim index ae0b655a..0d85829c 100644 --- a/ale_linters/sass/stylelint.vim +++ b/ale_linters/sass/stylelint.vim @@ -1,8 +1,31 @@ " Author: diartyz <diartyz@gmail.com> +let g:ale_sass_stylelint_executable = +\ get(g:, 'ale_sass_stylelint_executable', 'stylelint') + +let g:ale_sass_stylelint_use_global = +\ get(g:, 'ale_sass_stylelint_use_global', 0) + +function! ale_linters#sass#stylelint#GetExecutable(buffer) abort + if g:ale_sass_stylelint_use_global + return g:ale_sass_stylelint_executable + endif + + return ale#util#ResolveLocalPath( + \ a:buffer, + \ 'node_modules/.bin/stylelint', + \ g:ale_sass_stylelint_executable + \) +endfunction + +function! ale_linters#sass#stylelint#GetCommand(buffer) abort + return ale_linters#sass#stylelint#GetExecutable(a:buffer) + \ . ' --stdin-filename %s' +endfunction + call ale#linter#Define('sass', { \ 'name': 'stylelint', -\ 'executable': 'stylelint', -\ 'command': g:ale#util#stdin_wrapper . ' .sass stylelint', +\ 'executable_callback': 'ale_linters#sass#stylelint#GetExecutable', +\ 'command_callback': 'ale_linters#sass#stylelint#GetCommand', \ 'callback': 'ale#handlers#HandleStyleLintFormat', \}) 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 <diartyz@gmail.com> +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', \}) |