From 217284360d35711b751859ed27a7a3c3da300e85 Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 2 Aug 2018 23:44:12 +0100 Subject: Simplify the code for most linters and tests with closures --- ale_linters/html/htmlhint.vim | 14 ++++---------- ale_linters/html/tidy.vim | 6 +----- 2 files changed, 5 insertions(+), 15 deletions(-) (limited to 'ale_linters/html') diff --git a/ale_linters/html/htmlhint.vim b/ale_linters/html/htmlhint.vim index caa15bbb..234c1176 100644 --- a/ale_linters/html/htmlhint.vim +++ b/ale_linters/html/htmlhint.vim @@ -5,12 +5,6 @@ call ale#Set('html_htmlhint_options', '') call ale#Set('html_htmlhint_executable', 'htmlhint') call ale#Set('html_htmlhint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#html#htmlhint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'html_htmlhint', [ - \ 'node_modules/.bin/htmlhint', - \]) -endfunction - function! ale_linters#html#htmlhint#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'html_htmlhint_options') let l:config = l:options !~# '--config' @@ -25,14 +19,14 @@ function! ale_linters#html#htmlhint#GetCommand(buffer) abort let l:options = substitute(l:options, '--format=unix', '', '') endif - return ale#Escape(ale_linters#html#htmlhint#GetExecutable(a:buffer)) - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --format=unix %t' + return '%e' . ale#Pad(l:options) . ' --format=unix %t' endfunction call ale#linter#Define('html', { \ 'name': 'htmlhint', -\ 'executable_callback': 'ale_linters#html#htmlhint#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('html_htmlhint', [ +\ 'node_modules/.bin/htmlhint', +\ ]), \ 'command_callback': 'ale_linters#html#htmlhint#GetCommand', \ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/ale_linters/html/tidy.vim b/ale_linters/html/tidy.vim index 913cdade..cab8bc24 100644 --- a/ale_linters/html/tidy.vim +++ b/ale_linters/html/tidy.vim @@ -37,10 +37,6 @@ function! ale_linters#html#tidy#GetCommand(buffer) abort \) endfunction -function! ale_linters#html#tidy#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'html_tidy_executable') -endfunction - function! ale_linters#html#tidy#Handle(buffer, lines) abort " Matches patterns lines like the following: " line 7 column 5 - Warning: missing before @@ -67,7 +63,7 @@ endfunction call ale#linter#Define('html', { \ 'name': 'tidy', -\ 'executable_callback': 'ale_linters#html#tidy#GetExecutable', +\ 'executable_callback': ale#VarFunc('html_tidy_executable'), \ 'output_stream': 'stderr', \ 'command_callback': 'ale_linters#html#tidy#GetCommand', \ 'callback': 'ale_linters#html#tidy#Handle', -- cgit v1.2.3