folke / persistence.nvim

💾 Simple session management for Neovim
Apache License 2.0
591 stars 26 forks source link

Trigger SessionLoadPost upon load() #47

Closed patnr closed 2 weeks ago

patnr commented 5 months ago

For example, this enables bufferline ordering persistence, which relies on the SessionLoadPost autocmd, ref https://github.com/akinsho/bufferline.nvim/blob/b15c6daf5a64426c69732b31a951f4e438cb6590/lua/bufferline.lua#L116

In my testing, it was necessary to wrap it in defer_fn, but I don't actually know why.

Not to be confused with persisting pinned buffers, which seems to be available since https://github.com/LazyVim/LazyVim/pull/304/files

github-actions[bot] commented 3 weeks ago

This PR is stale because it has been open 60 days with no activity.

folke commented 2 weeks ago

That alreay gets triggered. You probably load the session in an autocmd. If so, just add nested=true to the autocmd

patnr commented 2 weeks ago

Thanks. I don't see how/where exactly SessionLoadPost gets triggered, but it does indeed appear to happen when loading the session in the normal manner. But my use case is launching directly from terminal as such nvim +"lua require(\"persistence\").load()" in which case SessionLoadPost does not appear to get triggered, which this PR fixes. Perhaps I'm going about it wrong?

folke commented 2 weeks ago

That even is triggered by neovim. Again, if it doesn work for you, it means you load the session from an autocmd without nested=trie.

There's nothing to fix here apart from your config.

Your PR would trigger the event twice in my case

patnr commented 2 weeks ago

Thanks. For reference, it seems the better solution is to list "akinsho/bufferline.nvim" as a dependency of "folke/persistence.nvim", in which case the bufferline ordering persists (also for my use case).

folke commented 2 weeks ago

Also, if you're testing with print, then that wouldn't work because session is loaded with silent. It still fires, but won't print

patnr commented 2 weeks ago

Not sure what you mean about "print"?