olimorris / persisted.nvim

💾 Simple session management for Neovim with git branching, autoloading and Telescope support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] Allow loading a session by name

akinsho opened this issue · comments

commented

Off the back of #46 something I'm trying to get in order to reach the goal that is a copy of the emacs-dashboard is the ability to load a session on demand without going through the telescope picker i.e. to have a list of session names and then load of those with just the name. I noticed a utils.load but this seems to be the raw logic and perhaps is not intended for use externally?

A command like SessionLoad name/of/my/session@@branch which correctly loads the session just like the telescope plugin does would be ideal.

commented

This is undocumented but there is an API available with require("persisted").list(). It should throw out a table like:

{
  {
    branch = "main",
    dir_path = ".dotfiles",
    file_path = "/Users/Oli/.local/share/nvim/sessions/%Users%Oli%.dotfiles@@main.vim",
    name = ".dotfiles@@main"
  },
  {
    branch = "main",
    dir_path = "Code/Java/hello_world",
    file_path = "/Users/Oli/.local/share/nvim/sessions/%Users%Oli%Code%Java%hello_world@@main.vim",
    name = "Code/Java/hello_world@@main"
  },
  {
    branch = "main",
    dir_path = "Code/Java/java-sample-app",
    file_path = "/Users/Oli/.local/share/nvim/sessions/%Users%Oli%Code%Java%java-sample-app@@main.vim",
    name = "Code/Java/java-sample-app@@main"
  },
}

where @@ is the branch separator in my case.

commented

Ah I had discovered that API but didn't realise that I could use the file path with the require('persisted.utils').load(filepath) to load the session right?

commented

Good point, I can add a method to load a specific session!

commented

Closed by #48