forked from rafi/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqf.vim
56 lines (47 loc) · 1.36 KB
/
qf.vim
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
44
45
46
47
48
49
50
51
52
53
54
55
56
" Snippets from vim-qf
" Credits: https://github.com/romainl/vim-qf
if exists('b:did_ftplugin')
finish
endif
let b:did_ftplugin = 1
let s:save_cpo = &cpoptions
set cpoptions&vim
let b:undo_ftplugin = 'setl fo< com< ofu<'
setlocal winminheight=1 winheight=3
setlocal nowrap
setlocal norelativenumber number
setlocal linebreak
setlocal nolist
setlocal cursorline
setlocal nobuflisted
wincmd J
nnoremap <buffer> <CR> <CR><C-w>p
nnoremap <buffer> sv <C-w><CR>
nnoremap <buffer> sg <C-w><Enter><C-w>L
nnoremap <buffer> st <C-w><CR><C-w>T
nnoremap <silent><buffer> p :call <SID>preview_file()<CR>
nnoremap <silent><buffer> q :pclose!<CR>:quit<CR>
nnoremap <buffer> o <CR><C-w>p
nnoremap <buffer> o <CR><C-w>p
let b:qf_isLoc = ! empty(getloclist(0))
if b:qf_isLoc == 1
nnoremap <buffer> O <CR>:lclose<CR>
else
nnoremap <buffer> O <CR>:cclose<CR>
endif
function! s:preview_file()
let winwidth = &columns
let cur_list = b:qf_isLoc == 1 ? getloclist('.') : getqflist()
let cur_line = getline(line('.'))
let cur_file = fnameescape(substitute(cur_line, '|.*$', '', ''))
if cur_line =~# '|\d\+'
let cur_pos = substitute(cur_line, '^\(.\{-}|\)\(\d\+\)\(.*\)', '\2', '')
execute 'vertical pedit! +'.cur_pos.' '.cur_file
else
execute 'vertical pedit! '.cur_file
endif
wincmd P
execute 'vert resize '.(winwidth / 2)
wincmd p
endfunction
let &cpoptions = s:save_cpo