All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Vincent Lequertier <https://github.com/SkySymbol>
2 " Description: This file adds support for checking perl syntax
4 call ale#Set('perl_perl_executable', 'perl')
5 call ale#Set('perl_perl_options', '-c -Mwarnings -Ilib')
7 function! ale_linters#perl#perl#GetCommand(buffer) abort
8 return '%e' . ale#Pad(ale#Var(a:buffer, 'perl_perl_options')) . ' %t'
11 let s:begin_failed_skip_pattern = '\v' . join([
12 \ '^Compilation failed in require',
16 function! ale_linters#perl#perl#Handle(buffer, lines) abort
21 let l:pattern = '\(..\{-}\) at \(..\{-}\) line \(\d\+\)'
23 let l:basename = expand('#' . a:buffer . ':t')
27 if a:lines[-1] =~# 'syntax OK'
33 for l:match in ale#util#GetMatches(a:lines, l:pattern)
34 let l:line = l:match[3]
35 let l:file = l:match[2]
36 let l:text = l:match[1]
38 if ale#path#IsBufferPath(a:buffer, l:file)
39 \ && !has_key(l:seen,l:line)
41 \ l:text isnot# 'BEGIN failed--compilation aborted'
43 \ || match(l:output[-1].text, s:begin_failed_skip_pattern) < 0
51 let l:seen[l:line] = 1
58 call ale#linter#Define('perl', {
60 \ 'executable': {b -> ale#Var(b, 'perl_perl_executable')},
61 \ 'output_stream': 'both',
62 \ 'command': function('ale_linters#perl#perl#GetCommand'),
63 \ 'callback': 'ale_linters#perl#perl#Handle',