folke / persistence.nvim

💾 Simple session management for Neovim
Apache License 2.0
655 stars 25 forks source link

feature: Optionally save Session.vim file in current directory as well #41

Closed shaun-mathew closed 3 months ago

shaun-mathew commented 9 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I am currently using tmux-resurrect (https://github.com/tmux-plugins/tmux-resurrect/tree/master) to restore tmux sessions. This plugin has an optional neovim integration where it looks for a Session.vim file in the current folder and loads the neovim/vim session (See https://github.com/tmux-plugins/tmux-resurrect/blob/master/docs/restoring_vim_and_neovim_sessions.md). Since Persistence.nvim stores the sessions in a shared directory and not the current folder, tmux-resurrect cannot load neovim with the saved session.

Describe the solution you'd like

Have an additional option to save a Session.vim file in the working directory as well or a symlink. The option could look like this.

{
  dir = vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/"), -- directory where session files are saved
  options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
  pre_save = nil, -- a function to call before saving the session
  save_empty = false, -- don't save if there are no open file buffers
  save_session_vim = true, -- create a Session.vim file in the project directory as well
}

Describe alternatives you've considered

tpope has the vim-obsession plugin, but I'm currently using lazyvim and I'd rather use the integrated solution.

Additional context

No response

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

folke commented 3 months ago

You can write a simple autocmd on VimLeave that writes a .vim file in the current directory that just does lua require('persistence').load()