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

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

Open shaun-mathew opened this issue 2 years ago • 1 comments

Did you check the docs?

  • [X] I have read all the persistence.nvim 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

shaun-mathew avatar Dec 23 '23 21:12 shaun-mathew

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.

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

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

folke avatar Jul 06 '24 19:07 folke