Skip to content
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

Close Panel when the last Buffer is closed #13

Open
tuxflo opened this issue Apr 8, 2019 · 1 comment
Open

Close Panel when the last Buffer is closed #13

tuxflo opened this issue Apr 8, 2019 · 1 comment

Comments

@tuxflo
Copy link

tuxflo commented Apr 8, 2019

Hi!
Since NERDTree has some serious issues with session management I want to give vimpanel a try. In NERDTree I used to have the following line in my vimrc to ensure that NERDTree is closed if the last buffer was closed:

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

Is there a way to achieve the same behaviour (or even a better one that automatically saves the session) with vimpanel?

@mihaifm
Copy link
Owner

mihaifm commented Apr 9, 2019

Hi

I haven't updated this plugin in a while but any feedback is appreciated.

I don't fully understand your workflow, but you can achieve this with the command below, although it's a bit hacky:

autocmd bufenter * if (winnr("$") == 1 && bufwinnr("vimpanel-") > 0 && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1) | q | endif

winnr("$") == 1 This checks if there is only one window active
bufwinnr("vimpanel-") > 0 Checks if the buffer name starts with vimpanel-
len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 Counts the number of active buffers

However I see several problems with this:

  • it doesn't allow you to open a panel without having any other buffers in vim
  • it doesn't work with multiple panels, something that is supported by vimpanel but not NERDTree

So I would honestly not use this command. Instead you can just quit vimpanel as you do with any other buffer. This is easier compared with NERDTree because NERDTree uses a hidden buffer making things more complicated.

Regarding sessions, there is a VimpanelSessionMake command which allows you to save the session. It's a wrapper around the built-in mksession but also saves the layout of the panel (or panels, since you can have more than one with vimpanel).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants