Adding a Session list to sidebar-nvim
Adding a Session list to sidebar-nvim
So, instead of running to reddit, i'll give this a shot here. I'm in the process of making my own NeoVim Configuration from scratch. One of the tools i use is sidebar-nvim . This allows me to make my own Sections. I'm pretty new to lua and have never dabbled in plugin programming before. Through reading the source of sidebar-nvim and neovim-session-manager I have gotten to a point where i get a list of my sessions in the sidebar.
local session_manager = require("session_manager.utils")
local sessions = session_manager.get_sessions()
local dirs = {}
local filenames = {}
for _, file, _ in pairs(sessions) do
local directory = session_manager.shorten_path(file.dir)
table.insert(dirs, directory)
table.insert(filenames, file.filename)
end
local section = {
title = "Sessions",
icon = " ",
draw = function()
return dirs
end,
bindings = {
["l"] = function(line, col)
local filename = filenames[line]
session_manager.load_session(filename, false)
end,
}
}
return {
"sidebar-nvim/sidebar.nvim",
config = function()
require("sidebar-nvim").setup({
open = true,
side = "right",
sections = {
"datetime",
"symbols",
section,
"git",
"todos",
"diagnostics"
},
})
end
}
The thing that isn't working is the "bindings". session_manager.load_session takes the filename out of the original sessions table. I have no clue how the original structure looks. My attempt currently returns an empty value. Anyone have an idea how to access the data i need to get the session loaded properly?