Closed dylan-chong closed 6 years ago
:set sessionoptions+=globals
should do the trick.
I think you misunderstand what I'm asking for. I don't want to save heaps just one. If I save lots of globals then I can't use :wqa and nvim -S to test out a "clean" vim setup, especially when I'm tinkering with lots of settings. I won't get as clean of a setup if lots of globals are reloaded when reloading the session
I do need to store a particular global variable because this plug in here needs to store a global variable in order to save state across sessions https://github.com/zefei/vim-wintabs
On 16/06/2018, at 9:33 AM, Tim Pope notifications@github.com wrote:
Closed #44.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
I think you misunderstand what sessionoptions+=globals
does. It's CamelCase variables only. Then again I have no idea what "heaps" are so it's clear I don't 100% understand what you're talking about either.
I think you misunderstand what sessionoptions+=globals does. It's CamelCase variables only. Then again I have no idea what "heaps" are so it's clear I don't 100% understand what you're talking about either.
Sorry yes I should have been clearer about this. I mean that lots of plug-ins store global variables to store state.
There are also global variables that I might set by myself in order to configure a plug-in, inside my vimrc file. For example, I might be playing around with a new plug-in, trying out different configurations. I might realise that I don't actually need to set those global variables for the plug-in. I would then remove those global variables from my vimrc.
When I remove those global variables from my vimrc, I need to be able to cleanly reload Vim. I also may have various tabs open, and do not want to lose them, hence using sessions. And by cleanly reloading vim, I mean that global variables (except ones I choose) should not persist across the session. If they do persist across the session, then I am not really testing a clean start up of vim.
By listing all of the global variables and then filtering the ones starting with a capital letter, I get 176 global variables --- only two of which I want to keep for the plug-in wintabs. The other 174 are from various plug-ins -- which i do not want to store in the session.
Hopefully this clarifies why I would like to store specific global variables. Please do ask for clarification again if I was in very good with my explanation again
I know this isn't a particularly helpful answer, but I'm inclined to blame these plugins for giving their variables bad names. Admittedly it's an easy mistake for a plugin author to make if they don't personally use sessions, but at the end of the day, if it doesn't make sense to store in the session, it shouldn't start with a capital letter. I would urge you to consider reaching out to some of the bigger offenders, even if it seems like a bit of a lost cause.
I would entertain adding some sort of callback so you can mutate the session yourself, but I don't think I want Obsession to take responsibility for (and implicitly endorse) this practice.
vim-session actually has this functionality already but unfortunately that plug-in is not maintained any more.
Basically I want to use this because vim-wintabs stores state through a session by storing a global variable with data about each buffer open. Being able to save a specific global variable is a very nice feature.