From d84533d1e9eea28deb5089a66559774a68cb55a3 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Wed, 12 Apr 2023 14:44:43 +0100 Subject: [PATCH] vim: update togglelist to also work in nvim I think the Quickfix window has been renamed which caused this to stop working. The approach of using [cl]window seems better. --- vim/after/plugin/togglelist.vim | 47 +++++++++++---------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/vim/after/plugin/togglelist.vim b/vim/after/plugin/togglelist.vim index dbb06f1..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 -- 2.48.1