summaryrefslogtreecommitdiffstats
path: root/vim
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-01-22 18:53:00 -0600
committerJesse Luehrs <doy@tozt.net>2012-01-22 18:53:29 -0600
commit4277d4bde6afb45ee6f624ca28af007fc656b13b (patch)
treefa50a26d7f62e77bc703fa29301f0c7de5864bc8 /vim
parent8fdbe47ab75f438a104514d2ea9e5f155ee5ac10 (diff)
downloadconf-4277d4bde6afb45ee6f624ca28af007fc656b13b.tar.gz
conf-4277d4bde6afb45ee6f624ca28af007fc656b13b.zip
try out an implementation of flymake for perl stuff
Diffstat (limited to 'vim')
-rw-r--r--vim/ftplugin/perl.vim59
1 files changed, 59 insertions, 0 deletions
diff --git a/vim/ftplugin/perl.vim b/vim/ftplugin/perl.vim
index b86d4e2..593dc4b 100644
--- a/vim/ftplugin/perl.vim
+++ b/vim/ftplugin/perl.vim
@@ -45,3 +45,62 @@ function! s:unpostfix()
endfunction
map <buffer> <silent> <Leader>i :call <SID>unpostfix()<CR>
+
+" reimplement :make, since it always prints to the screen, which is annoying
+function! Make()
+ if exists('#QuickFixCmdPre')
+ doau QuickFixCmdPre make
+ endif
+
+ cexpr ""
+
+ let buffer_contents = join(getbufline("", 1, '$'), "\n")
+ let output = system("perl -c -Ilib", buffer_contents)
+ let lines = split(output, "\n")
+
+ for line in lines
+ let match = matchlist(line, '\(.\+\) at - line \(\d\+\)')
+ if !empty(match)
+ caddexpr expand('%') . ':' . match[2] . ':' . match[1]
+ endif
+ endfor
+
+ if exists('#QuickFixCmdPost')
+ doau QuickFixCmdPost make
+ endif
+endfunction
+
+function! HighlightCurrent()
+ exe '1wincmd w'
+ try
+ syntax clear CompileError
+ catch /E28/
+ endtry
+ let qlist = getqflist()
+ for q in qlist
+ let line = substitute(getline(q['lnum']), '\', '\\\\', 'g')
+ exe 'syntax match CompileError /\%' . q['lnum'] . 'l' . line . '/'
+ endfor
+ highlight CompileError ctermbg=red guibg=red
+endfunction
+
+function! UpdateStatusLine()
+ let qlist = getqflist()
+ let lnum = getpos('.')[1]
+ for q in qlist
+ if lnum == q["lnum"]
+ let text = q["text"]
+ let width = &columns - 52
+ if strlen(text) > width - 3
+ let text = strpart(text, 0, width - 3) . '...'
+ endif
+ echo text
+ return
+ endif
+ endfor
+ echo ""
+endfunction
+
+au BufEnter,BufWritePost <buffer> call Make()
+au QuickFixCmdPost <buffer> call HighlightCurrent()
+au CursorMoved <buffer> call UpdateStatusLine()