diff options
author | Steven Humphrey <shumphrey@users.noreply.github.com> | 2017-06-11 21:13:47 +0100 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-06-11 21:13:47 +0100 |
commit | 99263bdda446ec9c28ab92c3cafe8b166ac7fca8 (patch) | |
tree | 5fe88feff10c341315a3619df399a2b81e9a30a4 /ale_linters/perl | |
parent | 64ad51048d8f490b57ca6e74864f4de3777ec2a7 (diff) | |
download | ale-99263bdda446ec9c28ab92c3cafe8b166ac7fca8.zip |
Perlcritic column number and rule names (#640)
* Add column number to perlcritic linting output
This returns the column number of the perlcritic error so that ale can
show the column in addition to the line where perlcritic found an error.
* Add perlcritic configuration for rule names
This adds a configuration setting so that the name of the perlcritic
rule is shown [Rule::Name] after the error message.
This is useful to lookup the rule failure.
* Add a vader test for perlcritic#GetCommand
Diffstat (limited to 'ale_linters/perl')
-rw-r--r-- | ale_linters/perl/perlcritic.vim | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/ale_linters/perl/perlcritic.vim b/ale_linters/perl/perlcritic.vim index f0e85030..189a9ce3 100644 --- a/ale_linters/perl/perlcritic.vim +++ b/ale_linters/perl/perlcritic.vim @@ -1,14 +1,29 @@ " Author: Vincent Lequertier <https://github.com/SkySymbol> " Description: This file adds support for checking perl with perl critic +if !exists('g:ale_perl_perlcritic_showrules') + let g:ale_perl_perlcritic_showrules = 0 +endif + +function! ale_linters#perl#perlcritic#GetCommand(buffer) abort + let l:critic_verbosity = '%l:%c %m\n' + if g:ale_perl_perlcritic_showrules + let l:critic_verbosity = '%l:%c %m [%p]\n' + endif + + return "perlcritic --verbose '". l:critic_verbosity . "' --nocolor" +endfunction + + function! ale_linters#perl#perlcritic#Handle(buffer, lines) abort - let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)' + let l:pattern = '\(\d\+\):\(\d\+\) \(.\+\)' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'text': l:match[1], - \ 'lnum': l:match[3], + \ 'lnum': l:match[1], + \ 'col': l:match[2], + \ 'text': l:match[3], \}) endfor @@ -19,6 +34,6 @@ call ale#linter#Define('perl', { \ 'name': 'perlcritic', \ 'executable': 'perlcritic', \ 'output_stream': 'stdout', -\ 'command': 'perlcritic --verbose 3 --nocolor', +\ 'command_callback': 'ale_linters#perl#perlcritic#GetCommand', \ 'callback': 'ale_linters#perl#perlcritic#Handle', \}) |