]> git.rmz.io Git - dotfiles.git/blob - vim/after/plugin/togglelist.vim
vim: create new undo block before capitalising previous word
[dotfiles.git] / vim / after / plugin / togglelist.vim
1 " toggle unite, quickfix list and location list
2 if exists("g:loaded_toggle_list")
3 finish
4 endif
5 let g:loaded_toggle_list = 1
6
7 " Inspired by
8 " https://github.com/drmingdrmer/vim-toggle-quickfix/blob/master/autoload/togglequickfix.vim
9 function! s:ToggleLocationList()
10 let last = winnr('$')
11 let cur = winnr()
12 try
13 lwindow 10
14 catch /E776/
15 echohl WarningMsg | echon 'No Location List' | echohl None
16 endtry
17 if winnr('$') == last
18 lclose
19 elseif winnr() != cur
20 wincmd p
21 endif
22 endfunction
23
24 function! s:ToggleQuickfixList()
25 let last = winnr('$')
26 let cur = winnr()
27 cwindow 10
28 if winnr('$') == last
29 cclose
30 elseif winnr() != cur
31 wincmd p
32 endif
33 endfunction
34
35
36 function! s:ToggleUnite()
37 for i in range(1, winnr('$'))
38 let name = bufname(winbufnr(i))
39 if match(name, '^\[unite\]') == 0
40 UniteClose
41 return
42 endif
43 endfor
44 UniteResume
45 endfunction
46
47 nnoremap <silent> [oq :copen<cr>
48 nnoremap <silent> ]oq :cclose<cr>
49 nnoremap <silent> coq :call <SID>ToggleQuickfixList()<CR>
50 nnoremap <silent> [ol :lopen<cr>
51 nnoremap <silent> ]ol :lclose<cr>
52 nnoremap <silent> col :call <SID>ToggleLocationList()<CR>
53 nnoremap <silent> cop :pclose<CR>