blob: 9492f1d608afaa97172c992635b86a537f177045 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
let b:ale_linters = { 'perl': ['perlcritic'] }
" :make does a syntax check
if expand("%:e") == "psgi"
exe 'setlocal makeprg=plackup\ -Ilib\ -a\ ' . expand("%")
else
setlocal makeprg=$VIMRUNTIME/tools/efm_perl.pl\ -c\ %\ $*
setlocal errorformat=%f:%l:%m
endif
" look up words in perldoc rather than man for K
function! s:perldoc(word)
let perldoc_pager = $PERLDOC_PAGER
let $PERLDOC_PAGER = 'cat'
exe 'silent read! perldoc -f "' . a:word . '" 2>/dev/null || perldoc "' . a:word . '"'
let $PERLDOC_PAGER = perldoc_pager
set ft=man
endfunction
nmap <buffer> <silent>K :call Help(0, [':'], '<SID>perldoc')<CR>
vmap <buffer> <silent>K :call Help(1, [':'], '<SID>perldoc')<CR>
function! s:unpostfix()
let postop_pattern = '\<\(if\|unless\|while\|until\|for\)\>'
let indent = repeat(' ', &sw)
if getline('.') =~ postop_pattern
normal kJ
else
normal J
endif
" XXX this doesn't insert newlines properly
" let line = getline('.')
" let line = substitute(
" \line,
" \'\(\s*\)\(.*\) ' . postop_pattern . ' \(.*\);',
" \'\1\3 (\4) {\1' . indent . '\2;\n\1}',
" \''
" \)
" call setline('.', line)
exe 's/\(\s*\)\(.*\) ' . postop_pattern . ' \(.*\);/\1\3 (\4) {\r\1' . indent . '\2;\r\1}/'
endfunction
map <buffer> <silent> <Leader>i :call <SID>unpostfix()<CR>
|