diff options
Diffstat (limited to 'ale_linters')
-rwxr-xr-x | ale_linters/less/lessc.vim | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/ale_linters/less/lessc.vim b/ale_linters/less/lessc.vim index 76b7f133..8b7985a3 100755 --- a/ale_linters/less/lessc.vim +++ b/ale_linters/less/lessc.vim @@ -1,12 +1,25 @@ -" Author: zanona <https://github.com/zanona> +" Author: zanona <https://github.com/zanona>, w0rp <devw0rp@gmail.com> " Description: This file adds support for checking Less code with lessc. +call ale#Set('less_lessc_executable', 'lessc') call ale#Set('less_lessc_options', '') +call ale#Set('less_lessc_use_global', 0) + +function! ale_linters#less#lessc#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'less_lessc', [ + \ 'node_modules/.bin/lessc', + \]) +endfunction function! ale_linters#less#lessc#GetCommand(buffer) abort - return 'lessc' - \ . ' --no-color --lint --include-path=' . expand('%:p:h') - \ . ' ' . ale#Var(a:buffer, 'less_lessc_options') + let l:executable = ale_linters#less#lessc#GetExecutable(a:buffer) + let l:dir = expand('#' . a:buffer . ':p:h') + let l:options = ale#Var(a:buffer, 'less_lessc_options') + + return ale#Escape(l:executable) + \ . ' --no-color --lint' + \ . ' --include-path=' . ale#Escape(l:dir) + \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -' endfunction @@ -29,8 +42,8 @@ endfunction call ale#linter#Define('less', { \ 'name': 'lessc', -\ 'executable': 'lessc', -\ 'output_stream': 'stderr', +\ 'executable_callback': 'ale_linters#less#lessc#GetExecutable', \ 'command_callback': 'ale_linters#less#lessc#GetCommand', \ 'callback': 'ale_linters#less#lessc#Handle', +\ 'output_stream': 'stderr', \}) |