persistence.nvim icon indicating copy to clipboard operation
persistence.nvim copied to clipboard

Trigger SessionLoadPost upon load()

Open patnr opened this issue 1 year ago • 1 comments

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

patnr avatar Feb 25 '24 18:02 patnr

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

github-actions[bot] avatar Jul 06 '24 01:07 github-actions[bot]

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

folke avatar Jul 06 '24 19:07 folke

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?

patnr avatar Jul 07 '24 09:07 patnr

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

folke avatar Jul 07 '24 10:07 folke

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).

patnr avatar Jul 07 '24 10:07 patnr

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

folke avatar Jul 07 '24 10:07 folke

Not sure what you mean about "print"?

patnr avatar Jul 07 '24 10:07 patnr