forked from tony/vim-config-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickfix.vim
More file actions
66 lines (56 loc) · 1.58 KB
/
quickfix.vim
File metadata and controls
66 lines (56 loc) · 1.58 KB
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
57
58
59
60
61
62
63
64
65
66
autocmd QuickFixCmdPost *grep* cwindow
function! QFwinnr()
let i=1
while i <= winnr('$')
if getbufvar(winbufnr(i), '&buftype') == 'quickfix'
return i
endif
let i += 1
endwhile
return 0
endfunction
function! QFCurrent()
if getbufvar(winbufnr('%'), '&buftype') == 'quickfix'
return 1
else
return 0
endif
endfunction
function! BufTypeCurrent()
return getbufvar(winbufnr('%'), '&buftype')
endfunction
nnoremap <leader>q :call QuickfixToggle()<cr>
nnoremap <C-q> :call QuickfixToggle()<cr>
let g:quickfix_is_open = 0
function! QuickfixToggle()
if g:quickfix_is_open
cclose
let g:quickfix_is_open = 0
execute g:quickfix_return_to_window . "wincmd w"
else
let g:quickfix_return_to_window = winnr()
copen
let g:quickfix_is_open = 1
endif
endfunction
"augroup QuickFixMap
" autocmd! BufEnter * :if &buftype is# 'quickfix' | nnoremap <silent> <buffer> <C-p> :cp<CR> | endif
" autocmd! BufEnter * :if &buftype is# 'quickfix' | nnoremap <silent> <buffer> <Leader>p :cp<CR> | endif
" autocmd! BufEnter * :if &buftype is# 'quickfix' | nnoremap <silent> <buffer> <C-n> :cn<CR> | endif
" autocmd! BufEnter * :if &buftype is# 'quickfix' | nnoremap <silent> <buffer> <Leader>n :cn<CR> | endif
"augroup END
function! NextBufferOrQuickfix()
if QFwinnr()
execute ':cn'
else
execute ':bnext'
endif
endfunction
function! PrevBufferOrQuickfix()
"if &buftype=="quickfix"
if QFwinnr()
execute ':cp'
else
execute ':bprev'
endif
endfunction