From 2760cf7018893b42c4ae5c750a7f1d38669aa821 Mon Sep 17 00:00:00 2001 From: Oskar Grunning Date: Thu, 6 Dec 2018 19:23:31 +0100 Subject: refactor sasslint linter (#2077) Previous implementation required one to have sass-lint globally. This allows you to have it locally, override the executable and add options. --- ale_linters/scss/sasslint.vim | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'ale_linters/scss/sasslint.vim') diff --git a/ale_linters/scss/sasslint.vim b/ale_linters/scss/sasslint.vim index f6075001..8b725ba6 100644 --- a/ale_linters/scss/sasslint.vim +++ b/ale_linters/scss/sasslint.vim @@ -1,18 +1,28 @@ -" Author: KabbAmine - https://github.com/KabbAmine, Ben Falconer -" +" Author: sQVe - https://github.com/sQVe + +call ale#Set('scss_sasslint_executable', 'sass-lint') +call ale#Set('scss_sasslint_options', '') +call ale#Set('scss_sasslint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#scss#sasslint#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'scss_sasslint', [ + \ 'node_modules/sass-lint/bin/sass-lint.js', + \ 'node_modules/.bin/sass-lint', + \]) +endfunction function! ale_linters#scss#sasslint#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) - \ . ale#Escape('sass-lint') - \ . ' -v' - \ . ' -q' - \ . ' -f compact' - \ . ' %t' + let l:executable = ale_linters#scss#sasslint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'scss_sasslint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -v -q -f compact %t' endfunction call ale#linter#Define('scss', { \ 'name': 'sasslint', -\ 'executable': 'sass-lint', +\ 'executable_callback': 'ale_linters#scss#sasslint#GetExecutable', \ 'command_callback': 'ale_linters#scss#sasslint#GetCommand', \ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \}) -- cgit v1.2.3