Warn on empty location list
goodboy opened this issue · 1 comments
goodboy commented
I was using this plug I found some time ago until finding your lovely alternative:
function! toggle#GetBufferList()
redir =>buflist
silent! ls
redir END
return buflist
endfunction
function! toggle#ToggleList(bufname, pfx)
let buflist = toggle#GetBufferList()
for bufnum in map(filter(split(buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))')
if bufwinnr(bufnum) != -1
exec(a:pfx.'close')
return
endif
endfor
if a:pfx == 'l' && len(getloclist(0)) == 0
echohl ErrorMsg
echo "Location List is Empty."
return
endif
let winnr = winnr()
exec(a:pfx.'open')
if winnr() != winnr
wincmd p
endif
endfunction
The thing I miss is the error message that alerts you that the list is empty.
Not sure if you'd be cool with adding something like that or not?
Deleted user commented
@tgoodlet You can check my fork ListToggle.vim. I added this error handling and I'm using the <Plug>
special key. This allows for lazy loading in a plugin manager like vim-plug or dein.
Example:
Plug 'fszymanski/ListToggle.vim', {
\ 'on': ['<Plug>ListToggleQuickfixListToggle',
\ '<Plug>ListToggleLocationListToggle']
\ }
let g:listtoggle_no_maps = 1
nmap <Leader>q <Plug>ListToggleQuickfixListToggle
nmap <Leader>l <Plug>ListToggleLocationListToggle