-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Sessions do no longer auto-save on exit #222
Comments
can provide a function to check the current file in session or not then do something. |
That would be perfect. Thank you! |
when have time do this :) |
Do you want me to implement this? I won't have time today, but could do it tomorrow and create a PR if you like. |
why not :) |
@Leo310 I have implemented the feature so that it will only auto-save a session if there is more than one file open. If that's not the case, the existing session file will not be overwritten. Edit: what's also important is, that the auto-save functionality is only triggered after first creating or loading a session for the current directory using |
Weird, because I have more then one file open and it still doesn't overwrite the existing session. And on your edit: I did create a session with :SessionSave first, but this session is as I mentioned, just not overwritten, by the auto-save hook. Not sure what I am doing wrong |
@Leo310 whenever you reopen the directory, you will first have to load the session to enable auto-saving. If it still doesn't work for you, the issue has to lie somewhere else. I'm using this feature on a daily basis and it works just fine for me. |
Very weird:
Any idea why It still doesn't work? |
@Leo310 I found the issue. Apparently sessions are not saved when creating buffers through telescope. If you open files through NvimTree or using the standard showcase.mp4 |
@LeonHeidelbach Hmmm I think we have slightly different issues:
Maybe reopen this issue? |
@Leo310 I mean the auto-save feature does work for me as you can see in my video as long as I don't use telescope. The auto-save functionality is based on the existing session save method which does seem to have issues with buffers opened through telescope. You could try to verify that the custom auto-command callback does in fact get called, by simply commenting out the line In any case I would suggest you open a new issue for this, since auto-saving itself works for me. |
@LeonHeidelbach Ok then I will propably open a new issue. |
@Leo310 Oh, then your problem could be that you define the custom auto command within the plugin config function of your package manager. You should define the custom auto command in your main initialization lua. Give that a try and let me know if that fixes it. |
@LeonHeidelbach Sadly, also doesnt work :( |
@Leo310 Well, I really cannot say what's the issue without further investigation then. You could try to execute the following commands and let me know what the outputs are: :lua print(require('dashboard').session_auto_save_on_exit) --> This should print 'true' if your config has been applied correctly
:lua print(require('dashboard.session').should_auto_save()) --> This should print 'true' if the first command prints 'true' and you have loaded or saved the current session
:lua vim.api.nvim_exec_autocmds('User', { pattern = 'DBSessionSavePre', modeline = false }) --> This should close your NvimTree buffer if you have one open |
Really Appreciate your help man, but everything works as expected 🤔 |
@Leo310 Sure thing. I mean I implemented this feature, so it might have been a mistake on my side, but I couldn't find anything wrong with the plugin code. Let me know if you find out what the issue was. |
@LeonHeidelbach fixed it by commenting out these lines. |
@Leo310 That is very strange. But you said that all of the commands I listed printed 'true' right? That means that the variable should've also been set correctly if this returns 'true': :lua print(require('dashboard').session_auto_save_on_exit) Maybe it get's reset somewhere else? |
@LeonHeidelbach yeah it returns true. But I wouldnt know where this should be reset. and there is no possibility that the this variable is set after this plugin is initialized? |
that is the only place I set it. Maybe something with the Lazy.nvim package manager and its lazy loading? |
so weird |
Yeah, well that could be. I personally still use Packer, since it's been around for quite some time and it's mostly stable. I need my package manager to work reliably and lazy.nvim probably still has quite some issues since it's just been released. |
I have no experience in building plugins or something like that so no idea what exactly could cause this in Lazy.nvim. |
I have no idea how Lazy.nvim actually works internally, but it could be a caching issue. Maybe Lazy is pre-computing some plugin tables to make things faster. I remember reading in its documentation, that it also natively implements similar functionality to impatient.nvim. But if it's a caching issue your other config values should not work either. It's a strange issue... You could maybe try to print the value of |
yeah very strange. and it's actually false where I commented out the if statement |
Yeah that works and is what I am doing atm. |
I would open an issue with Lazy.nvim for that since it's a pretty big problem. It's also still unclear what is causing this exactly. If you want to be sure and take the time you could try switching your package manager to Packer and see if you are still getting this config issue with your setup. If not, there is no doubt that it really is a Lazy issue. Specifically with preserving the config state after loading the plugin. |
Hi! I just saw this issue. Is it expected that a user does Lazy doesn't precompute anything or caches that sort of data btw. |
I just pushed an update that might fix this. @Leo310 would be great if you could confirm |
Hey @folke! Nice to see a direct response to this random issue from you here, how did you even find this? 😄 Dashboard does not have a dedicated setup function, instead users are supposed to directly change values within the "db" settings table located here like so: |
The problem was that |
maybe can use |
@folke yeah it is working now 👌. Also wondering how you find this issue? |
I'm searching Github every now and then to find any issues that might be caused by lazy ;) |
real sick man. i was a bit to lazy to open a new issue, so love your effort :) |
So, I had to revert that change, since that did break some plugins. I was also not really in favor of that change to begin with. When loading a plugin, the paths are added to the rtp, plugin files are sourced and once it's completely loaded, only then the user's I think it makes more sense to indeed change the dashboard code to only check if sessions need to be enabled on Or you could even always create the autosave autocmd and on VimLeavePre check if you need to save it or something... All those other autocmds are not a problem, since their callback code executes on events after sourcing the plugin file. I hope this makes sense... |
@folke maybe instead of changing when Lazy calls the |
I would like to keep it simple. config runs when the plugin was loaded, meaning that everything related to the plugin is loaded and available to be used in the config function. This is also how native packages with Pakadd would work. @glepnir 's suggestion and what i commented is an easy fix and makes more sense. |
I see that this issue is closed. Well I just hit this - no autosaving. I'm using Telescope like a billion other people. |
@glepnir Sessions do no longer auto-save when closing out of neovim and a session already exists for the current directory. It would be nice to either have a setup option to re-enable this functionality natively or for you to expose the project_name function in the session module so that users could easily implement this functionality themselves. As of now, to find the correct session one would have to copy your code to get the session file name in order to check if it exists for the cwd and depending on that call "session_save" on closing out of neovim.
The text was updated successfully, but these errors were encountered: