Closed ales-tsurko closed 12 months ago
Good afternoon and thank you for opening this issue. I am currently on holidays till end of the month with limited access to computers, I will look into it when I am back.
Meanwhile could you explain what exactly you mean by "closing" a session? A session is basically a file that lists a set of buffers to be loaded: what do you expect to happen when closing one?
Hi Gennaro! Thanks for quick reply. I meant something close to the next workflow:
Thanks! And happy holidays!
Notice that in vim there is no concept of closing a session, a session being nothing but a list of loaded buffers; as such, when you say that both possession.nvim
and vim-startify
allow you to "close and go back" what exactly happens to the buffers that are loaded in memory? Are they saved and closed under the hood or are they left in memory (and then you open a new dashboard buffer on top)?
It would be useful to first reproduce what those plugins do (I have used vim-startify
myself in the past and I don't remember any functionality to close and restart a session afresh) for me to better understand how to address this workflow.
Notice that in vim there is no concept of closing a session
I know this, that's why I used quotes (i.e. "close") initially.
I don't know how it's implemented in those plugins, but I'm pretty sure the buffers, tabs and windows are closed, when you "close" a session - that's the point. You close everything and go back to the start screen and then if you open any buffers or tabs or just want to edit some new file it won't affect the previous session. Actually, it feels like there is no session, when you close one. But maybe there's some kind of a default session, which aren't allowed to be updated, so when you opt-in autosave, the default session won't be changed, and you are able to start the starting screen again.
It would be useful to first reproduce what those plugins do (I have used vim-startify myself in the past and I don't remember any functionality to close and restart a session afresh) for me to better understand how to address this workflow.
In vim-startify
there is a command SClose
for this.
I had a look at the code in vim-startify
: what it does when closing is saving the session, deleting all the open buffers and invoking the starting screen again. However, are you sure that if you were to save the session again it wouldn't still overwrite the old one (that you have closed)? My understanding is that it would (because you are in the same working directory).
Essentially let's reproduce the following:
my_session
)Sclose
or similar mechanisms provided by those plugins)my_session
or where else is it saving the new session?Yesterday I configured pesrsisted.nvim for session management. It doesn't have the closing function, but it has SessionStop
, which stops watching for the session and updating the session file. On top of it I just wrote a command SessionClose
, which first SessionStop
, and then %bd
to delete all buffers and cd
to go back to the home directory. It works pretty well and I think the mechanics for "close" command in other plugins is similar to this. The plugin also have an option to disable autoloading session in case you switch the directory (which is related to the potential issue you noticed). I think it's worth looking how it's done there.
Yes, that could be done. However after the session is stopped/closed and you save a new one, would this override or create a new session file?
It seems to be that the closing of the sessions is essentially just a mechanism that deletes all loaded buffers (but my doubt is that if you started neovim with a session and/or load one, closing the buffers won't really get rid of the session "status", only simulate a blank directory).
I described the workflow I've been sticking to for a few years. It allowed me to switch between sessions and starting new sessions from scratch without leaving vim. As I've already solved the issue using another plugin, feel free to close this issue if you don't think you need it in your plugin. As just a user I can't provide you with details for an implementation of this feature, unfortunately. I haven't tried to implement something like this as a plugin. So I can just describe my particular use case. Thanks for the quick reply and help!
I am asking exactly because I want to understand what's the users are expecting, I am not asking you to help implement it :). Whilst you have described the workflow you used, you haven't answered whether closing the session still overrides the old one (which is the default vim behaviour, the only way to actually close a session being to exit vim) - which is the key mechanism that I am trying to understand here (deleting the buffers and opening the start page only "simulates" a new environment but still keeps the old session open unless you change directory).
I will anyway investigate a little more, in the meanwhile I am glad you have already found a solution/workaround!
I'd like to "close" a session to return to the dashboard and being able to start a new session from scratch or don't use any session at all. This is possible in
vim-startify
andposession.nvim
. Can I somehow do this using this plugin?