summaryrefslogtreecommitdiff
path: root/ale_linters/less
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-12 11:25:24 +0000
committerw0rp <devw0rp@gmail.com>2017-11-12 11:25:24 +0000
commitcd5da50531d55c003de495d8b151c60c5dbf26eb (patch)
tree58fa28991dce13335d3353af1e571b4214c6d6a9 /ale_linters/less
parent3aff1df9615ccc95bb91910f82d43947dd835f28 (diff)
downloadale-cd5da50531d55c003de495d8b151c60c5dbf26eb.zip
Add tests for the command and executable callbacks, and make them use local node_modulse esxecutables like other linters
Diffstat (limited to 'ale_linters/less')
-rwxr-xr-xale_linters/less/lessc.vim25
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',
\})