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/perl/perlcritic.vim | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'ale_linters/perl/perlcritic.vim') diff --git a/ale_linters/perl/perlcritic.vim b/ale_linters/perl/perlcritic.vim index e91c8a03..8619a404 100644 --- a/ale_linters/perl/perlcritic.vim +++ b/ale_linters/perl/perlcritic.vim @@ -1,21 +1,10 @@ " Author: Vincent Lequertier , Chris Weyl " Description: This file adds support for checking perl with perl critic -let g:ale_perl_perlcritic_executable = -\ get(g:, 'ale_perl_perlcritic_executable', 'perlcritic') - -let g:ale_perl_perlcritic_profile = -\ get(g:, 'ale_perl_perlcritic_profile', '.perlcriticrc') - -let g:ale_perl_perlcritic_options = -\ get(g:, 'ale_perl_perlcritic_options', '') - -let g:ale_perl_perlcritic_showrules = -\ get(g:, 'ale_perl_perlcritic_showrules', 0) - -function! ale_linters#perl#perlcritic#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'perl_perlcritic_executable') -endfunction +call ale#Set('perl_perlcritic_executable', 'perlcritic') +call ale#Set('perl_perlcritic_profile', '.perlcriticrc') +call ale#Set('perl_perlcritic_options', '') +call ale#Set('perl_perlcritic_showrules', 0) function! ale_linters#perl#perlcritic#GetProfile(buffer) abort " first see if we've been overridden @@ -39,11 +28,11 @@ function! ale_linters#perl#perlcritic#GetCommand(buffer) abort let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer) let l:options = ale#Var(a:buffer, 'perl_perlcritic_options') - return ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer)) + return '%e' \ . ' --verbose ' . ale#Escape(l:critic_verbosity) \ . ' --nocolor' \ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '') - \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ale#Pad(l:options) endfunction @@ -66,7 +55,7 @@ endfunction call ale#linter#Define('perl', { \ 'name': 'perlcritic', \ 'output_stream': 'stdout', -\ 'executable_callback': 'ale_linters#perl#perlcritic#GetExecutable', +\ 'executable_callback': ale#VarFunc('perl_perlcritic_executable'), \ 'command_callback': 'ale_linters#perl#perlcritic#GetCommand', \ 'callback': 'ale_linters#perl#perlcritic#Handle', \}) -- cgit v1.2.3