[Feature] Allow loading a session by name
akinsho opened this issue · comments
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.
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.
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?
Good point, I can add a method to load a specific session!