-
-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toggle quickfix list #97
Comments
http://vim.1045645.n5.nabble.com/detecting-whether-the-quickfix-window-is-open-td1155292.html function! QuickFix_toggle()
for i in range(1, winnr('$'))
let bnum = winbufnr(i)
if getbufvar(bnum, '&buftype') == 'quickfix'
cclose
return
endif
endfor
copen
endfunction
nnoremap <silent> coq :call QuickFix_toggle()<cr> |
I've been using something similar in my configuration, and I have quite enjoyed it. Any change of getting this merged upstream? |
The same approach could probably be used for the location list aswell. It would be nice if the mappings would be consistent, as That leaves the location list, which acts differently from the quickfix list in that Any thoughts on the matter @tpope? Is this something that you feel go inline with unimpaired? |
Things got more complicated with other plugins, e.g. dispatch or vimtex; currently these functions have evolved to (also for location list): " Toggle quickfix window
function! QuickFix_toggle(disp)
for i in range(1, winnr('$'))
let bnum = winbufnr(i)
if getbufvar(bnum, '&buftype') == 'quickfix'
cclose
return
endif
endfor
if a:disp == 1
Copen " from dispatch
else
if exists("b:vimtex")
VimtexErrors
else
copen
endif
endif
endfunction
nnoremap <silent> coq :call QuickFix_toggle(0)<cr>
nnoremap <silent> cod :call QuickFix_toggle(1)<cr>
function! s:BufferCount() abort
return len(filter(range(1, bufnr('$')), 'buflisted(v:val)'))
endfunction
" Toggle Location List window
function! Location_toggle()
" https://github.com/Valloric/ListToggle/blob/master/plugin/listtoggle.vim
let buffer_count_before = s:BufferCount()
" Location list can't be closed if there's cursor in it, so we need
" to call lclose twice to move cursor to the main pane
silent! lclose
silent! lclose
if s:BufferCount() == buffer_count_before
lopen
endif
endfunction
nnoremap <silent> coe :call Location_toggle()<cr> |
I guess my main objection is I'm not sold on the maps. There are some okay compromises for I'm half tempted to use |
I personally haven't needed a toggle command since I added these mappings:
Having the connection to |
FWIW |
Actually
add delays and do not override built-ins which I would not want either. |
Sorry for bumping this old issue, but I was looking exactly for this kind functionality and was actually surprised that it wasn't already part of vim-unimpaired, as it feels like such a good fit. For now I've hacked together a really simple mapping satisfying my needs -- maybe this will be of some help to someone: function! ToggleQuickFix()
if getqflist({'winid' : 0}).winid
cclose
else
copen
endif
endfunction
command! -nargs=0 -bar ToggleQuickFix call ToggleQuickFix()
nnoremap yoq :ToggleQuickFix<CR> |
Using the
co
mappings would it be possible to include mappings to toggle the quickfix list, location list, etc? Something likecoq
for example?The text was updated successfully, but these errors were encountered: