|
@@ -0,0 +1,56 @@
|
|
1
|
+" To change mapping, just put
|
|
2
|
+" let g:perlcritic_map='whatever'
|
|
3
|
+" in your .vimrc
|
|
4
|
+" To change the color of
|
|
5
|
+function! <SID>PerlCritic()
|
|
6
|
+ set lazyredraw
|
|
7
|
+ " Close any existing cwindows.
|
|
8
|
+ cclose
|
|
9
|
+ let l:grepformat_save = &grepformat
|
|
10
|
+ let l:grepprogram_save = &grepprg
|
|
11
|
+ set grepformat&vim
|
|
12
|
+ set grepformat&vim
|
|
13
|
+ let &grepformat = '%f:%l:%m'
|
|
14
|
+ let &grepprg = 'perlcritic_vim'
|
|
15
|
+ if &readonly == 0 | update | endif
|
|
16
|
+ silent! grep! %
|
|
17
|
+ let &grepformat = l:grepformat_save
|
|
18
|
+ let &grepprg = l:grepprogram_save
|
|
19
|
+ let l:mod_total = 0
|
|
20
|
+ let l:win_count = 1
|
|
21
|
+ " Determine correct window height
|
|
22
|
+ windo let l:win_count = l:win_count + 1
|
|
23
|
+ if l:win_count <= 2 | let l:win_count = 4 | endif
|
|
24
|
+ windo let l:mod_total = l:mod_total + winheight(0)/l:win_count |
|
|
25
|
+ \ execute 'resize +'.l:mod_total
|
|
26
|
+ " Open cwindow
|
|
27
|
+ execute 'belowright copen '.l:mod_total
|
|
28
|
+ nnoremap <buffer> <silent> c :cclose<CR>
|
|
29
|
+ set nolazyredraw
|
|
30
|
+ redraw!
|
|
31
|
+ let tlist=getqflist() ", 'get(v:val, ''bufnr'')')
|
|
32
|
+ if empty(tlist)
|
|
33
|
+ if !hlexists('GreenBar')
|
|
34
|
+ hi GreenBar term=reverse ctermfg=white ctermbg=darkgreen guifg=white guibg=darkgreen
|
|
35
|
+ endif
|
|
36
|
+ echohl GreenBar
|
|
37
|
+ echomsg "Perl::Critic correct"
|
|
38
|
+ echohl None
|
|
39
|
+ cclose
|
|
40
|
+ endif
|
|
41
|
+endfunction
|
|
42
|
+
|
|
43
|
+ if !exists('g:perlcritic_map')
|
|
44
|
+ let g:perlcritic_map='<F5>'
|
|
45
|
+ endif
|
|
46
|
+if ( !hasmapto('<SID>PerlCritic()') && (maparg(g:perlcritic_map) == '') )
|
|
47
|
+ exe 'nnoremap <silent> '. g:perlcritic_map .' :call <SID>PerlCritic()<CR>'
|
|
48
|
+" map <F5> :call <SID>PerlCritic()<CR>
|
|
49
|
+" map! <F5> :call <SID>PerlCritic()<CR>
|
|
50
|
+else
|
|
51
|
+ if ( !has("gui_running") || has("win32") )
|
|
52
|
+ echo "Python Perl::Critic Error: No Key mapped.\n".
|
|
53
|
+ \ g:perlcritic_map ." is taken and a replacement was not assigned."
|
|
54
|
+ endif
|
|
55
|
+endif
|
|
56
|
+
|