Closed ZNielsen closed 2 years ago
@ZNON15 I don't think Minimap.vim supports anything like that. What you could try is setting up your own autocommand which checks for the number of windows open, then closes the minimap if more than 2 open (the minimap counts as a window).
You could use the WinNew
and WinClosed
events (see :help WinClosed
for details). On WinNew
, check the number of windows with winnr('$')
(see :help winnr()
), if more than 2, close the minimap. If you want it to open when you close the split, check on WinClosed
and open if at 1
(^ Untested, just spitballing)
Something like:
function! MyMinimapCloser() abort
if winnr('$') > 1
execute ':MinimapClose'
endif
endfunction
autocmd WinNew * call MyMinimapCloser()
^ Also not tested
Like all things vim, autocommands are a little weird. I recommend reading :help autocmd
and doing some stack overflow searches for why/how to use autocmd-groups, as IMO the documentation doesn't do a great job of stressing how important they are.
Thanks for the suggestion! I've tried it out and it does work. Though i did have trouble figuring out how to make it work properly, but I did manage to get a working result the way I want it.
function! MinimapFunction() abort
if winwidth('$') < 100
execute ':MinimapClose'
else
execute ':Minimap'
endif
endfunction
autocmd WinNew,WinEnter,WinClosed,WinLeave,BufRead,BufCreate * call MinimapFunction()
This is what I have working right now. I have it set to only close the minimap when on Vertical Split with winwidth('$')
by checking if the window width is below 100. If it is less than 100 it closes the minimap but if it isn't it opens. I did this so that the minimap won't just close when on Horizontal split because I realized I still want the minimap opened in that layout, and I only want it closed when I don't have much screen real-estate on the sides.
Nice, I like it! That's a good idea, thanks for sharing. I think I'll set that up on my laptop where screen real estate is more restricted.
While this issue is still open, I want to ask an different question before I open another issue. Is there any way to block or close the Minimap when on a different window layout? Like lets say I want the Minimap to close or not open at all when I do a Vertical or Horizontal Split layout on neovim. I've been fiddling with the close/block buftypes/filetypes settings but I can't seem to get it to work. Is this currently not possible?
Originally posted by @ZN0N15 in https://github.com/wfxr/minimap.vim/issues/127#issuecomment-994669827