diff options
-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 | ||||
-rw-r--r-- | autoload/ale/handlers.vim | 6 | ||||
-rw-r--r-- | doc/ale.txt | 90 |
6 files changed, 195 insertions, 12 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', \}) diff --git a/autoload/ale/handlers.vim b/autoload/ale/handlers.vim index b7da32f2..4f1611f3 100644 --- a/autoload/ale/handlers.vim +++ b/autoload/ale/handlers.vim @@ -203,8 +203,8 @@ function! ale#handlers#HandleStyleLintFormat(buffer, lines) abort continue endif - let l:text = l:match[4] - let l:type = l:match[3] + let l:type = l:match[3] ==# '✖' ? 'E' : 'W' + let l:text = l:match[4] . '[' . l:match[5] . ']' " vcol is Needed to indicate that the column is a character. call add(l:output, { @@ -213,7 +213,7 @@ function! ale#handlers#HandleStyleLintFormat(buffer, lines) abort \ 'vcol': 0, \ 'col': l:match[2] + 0, \ 'text': l:text, - \ 'type': l:type ==# '✖' ? 'E' : 'W', + \ 'type': l:type, \ 'nr': -1, \}) endfor diff --git a/doc/ale.txt b/doc/ale.txt index 6ee90a51..3d8412e8 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -600,6 +600,27 @@ g:ale_html_htmlhint_options *g:ale_html_htmlhint_options* This variable can be changed to modify flags given to HTMLHint. +g:ale_html_htmlhint_executable *g:ale_html_htmlhint_executable* + + Type: |String| + Default: `'htmlhint'` + + ALE will first discover the htmlhint path in an ancestor node_modules + directory. If no such path exists, this variable will be used instead. + + If you wish to use only a globally installed version of htmlhint, set + |g:ale_html_htmlhint_use_global| to `1`. + + +g:ale_html_htmlhint_use_global *g:ale_html_htmlhint_use_global* + + Type: |String| + Default: `0` + + This variable controls whether or not ALE will search for a local path for + htmlhint first. If this variable is set to `1`, then ALE will always use the + global version of htmlhint, in preference to locally installed versions of + htmlhint in node_modules. ------------------------------------------------------------------------------- 4.16. c-clang *ale-linter-options-c-clang* @@ -676,6 +697,75 @@ g:ale_lacheck_executable *g:ale_lacheck_executable* This variable can be changed to change the path to lacheck. +------------------------------------------------------------------------------- +4.21. stylelint *ale-linter-options-stylelint* + +g:ale_css_stylelint_executable *g:ale_css_stylelint_executable* + + Type: |String| + Default: `'stylelint'` + + ALE will first discover the stylelint path in an ancestor node_modules + directory. If no such path exists, this variable will be used instead. + + If you wish to use only a globally installed version of stylelint, set + |g:ale_css_stylelint_use_global| to `1`. + + +g:ale_css_stylelint_use_global *g:ale_css_stylelint_use_global* + + Type: |String| + Default: `0` + + This variable controls whether or not ALE will search for a local path for + stylelint first. If this variable is set to `1`, then ALE will always use the + global version of stylelint, in preference to locally installed versions of + stylelint in node_modules. + +g:ale_scss_stylelint_executable *g:ale_scss_stylelint_executable* + + Type: |String| + Default: `'stylelint'` + + ALE will first discover the stylelint path in an ancestor node_modules + directory. If no such path exists, this variable will be used instead. + + If you wish to use only a globally installed version of stylelint, set + |g:ale_scss_stylelint_use_global| to `1`. + + +g:ale_scss_stylelint_use_global *g:ale_scss_stylelint_use_global* + + Type: |String| + Default: `0` + + This variable controls whether or not ALE will search for a local path for + stylelint first. If this variable is set to `1`, then ALE will always use the + global version of stylelint, in preference to locally installed versions of + stylelint in node_modules. + +g:ale_scss_stylelint_executable *g:ale_scss_stylelint_executable* + + Type: |String| + Default: `'stylelint'` + + ALE will first discover the stylelint path in an ancestor node_modules + directory. If no such path exists, this variable will be used instead. + + If you wish to use only a globally installed version of stylelint, set + |g:ale_scss_stylelint_use_global| to `1`. + + +g:ale_scss_stylelint_use_global *g:ale_scss_stylelint_use_global* + + Type: |String| + Default: `0` + + This variable controls whether or not ALE will search for a local path for + stylelint first. If this variable is set to `1`, then ALE will always use the + global version of stylelint, in preference to locally installed versions of + stylelint in node_modules. + =============================================================================== 5. Linter Integration Notes *ale-linter-integration* |