A big shoutout to @simonmclean for this pull request. Previously we autoloaded a session file as soon as Neovim opened. The problem with this is that key plugins like LSP and Treesitter may not have been initialised. This would lead to syntax highlighting issues or LSPs not attaching to buffers in the session. Pushing this to Neovim's event loop via vim.schedule allows us to sensibly load the session after these key plugins. Fixing the tests was a little cumbersome as we needed to use plenary's async library but once figured out, we have some lovely robust async tests
I'm experiencing a bug whereby if I enable autoloading, I don't get any syntax highlighting on startup (until I trigger it with `:e` for example). I had the same issue with `persistence.nvim` (I made an auto command to get the same functionality). For both plugins, wrapping the call to `load` in `vim.schedule` solved the problem.
I don't really know enough about the inner workings of Neovim to explain this though.
This addresses #1 and allows the user to specify directories which the plugin will automatically save or load from. Alternatively, specify directories for which this behaviour will be ignored
Using `use_git_branch` in a non git enabled repo caused an error. This has been addressed by checking for the presence of a `.git` folder in the cwd. If no branch has been specified then we default to HEAD via the addition of `2>/dev/null` in our shell command
In further testing, it became clear that adding the global variables to the setup and start functions would be useful.
It also seemed to make sense to return boolean values to detect if Persistence has stopped (false) or is in active use (true).
In my statusline, I like to know if persistence.nvim is active. I have a simple helper function:
function using_session()
return (vim.g.using_persistance ~= nil)
end
which I reference and display a corresponding glyph
This creates session files like:
%Users%Oli%Code%Projects%persistance_feature%add-git-branch-to-session
enabling you to segment your project directory by git branch