X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/c680b2fc4a1f6553616d2c104611c6df2e3b7c21..b47ffe60e244c9165f40371736079320ea2d848b:/vim/after/plugin/togglelist.vim diff --git a/vim/after/plugin/togglelist.vim b/vim/after/plugin/togglelist.vim index 01ba8de..278362c 100644 --- a/vim/after/plugin/togglelist.vim +++ b/vim/after/plugin/togglelist.vim @@ -2,47 +2,32 @@ if exists("g:loaded_toggle_list") finish endif - let g:loaded_toggle_list = 1 -function! s:GetBufferList() - redir =>buflist - silent! ls - redir END - return buflist -endfunction - +" Inspired by +" https://github.com/drmingdrmer/vim-toggle-quickfix/blob/master/autoload/togglequickfix.vim function! s:ToggleLocationList() - for bufnum in map(filter(split(s:GetBufferList(), '\n'), 'v:val =~# "Location List"'), 'str2nr(matchstr(v:val, "\\d\\+"))') - lclose - return - endfor - let last = winnr('$') - + let cur = winnr() try - Errors - catch - try - lopen - catch /E776/ - endtry - endtry - if last == winnr('$') + lwindow 10 + catch /E776/ echohl WarningMsg | echon 'No Location List' | echohl None + endtry + if winnr('$') == last + lclose + elseif winnr() != cur + wincmd p endif endfunction function! s:ToggleQuickfixList() - for bufnum in map(filter(split(s:GetBufferList(), '\n'), 'v:val =~ "Quickfix List"'), 'str2nr(matchstr(v:val, "\\d\\+"))') - if bufwinnr(bufnum) != -1 - cclose - return - endif - endfor - let winnr = winnr() - copen 10 - if winnr() != winnr + let last = winnr('$') + let cur = winnr() + cwindow 10 + if winnr('$') == last + cclose + elseif winnr() != cur wincmd p endif endfunction @@ -59,9 +44,10 @@ function! s:ToggleUnite() UniteResume endfunction -nmap [oq :copen -nmap ]oq :cclose -nmap coq :call ToggleLocationList() -nmap [ol :lopen -nmap ]ol :lclose -nmap col :call ToggleQuickfixList() +nnoremap [oq :copen +nnoremap ]oq :cclose +nnoremap coq :call ToggleQuickfixList() +nnoremap [ol :lopen +nnoremap ]ol :lclose +nnoremap col :call ToggleLocationList() +nnoremap cop :pclose