feat(config): add dir option

main
Scott McKendry 2024-06-23 11:39:15 +12:00
parent 7a202fef6d
commit 52a51eca82
3 changed files with 7 additions and 5 deletions

View File

@ -8,6 +8,7 @@ local M = {}
--- @field path_substitutions? substitution[] A list of substitutions to apply to paths --- @field path_substitutions? substitution[] A list of substitutions to apply to paths
M.defaults = { M.defaults = {
path_substitutions = {}, path_substitutions = {},
dir = "session",
} }
M.opts = {} M.opts = {}

View File

@ -13,7 +13,7 @@ function M.delete_session(prompt_bufnr)
local opts = require("telescope._extensions.resession.config").opts local opts = require("telescope._extensions.resession.config").opts
local session = action_state.get_selected_entry() local session = action_state.get_selected_entry()
local encoded = utils.encode_session(session[1], opts) local encoded = utils.encode_session(session[1], opts)
require("resession").delete(encoded, { dir = "dirsession" }) require("resession").delete(encoded, { dir = opts.dir })
-- Refresh the picker -- Refresh the picker
actions.close(prompt_bufnr) actions.close(prompt_bufnr)
@ -27,7 +27,7 @@ function M.load_session(prompt_bufnr)
local session = action_state.get_selected_entry() local session = action_state.get_selected_entry()
local encoded = utils.encode_session(session[1], opts) local encoded = utils.encode_session(session[1], opts)
actions.close(prompt_bufnr) actions.close(prompt_bufnr)
require("resession").load(encoded, { dir = "dirsession" }) require("resession").load(encoded, { dir = opts.dir })
end end
--- Render the session picker --- Render the session picker

View File

@ -51,16 +51,17 @@ M.decode_sessions = function(sessions, opts)
end end
--- Get a list of sessions from resession --- Get a list of sessions from resession
--- @param opts config telescope-resession configuration
--- @return string[] The list of sessions --- @return string[] The list of sessions
M.get_sessions = function() M.get_sessions = function(opts)
return require("resession").list({ dir = "dirsession" }) return require("resession").list({ dir = opts.dir })
end end
--- Get a list of sessions from resession and decode them --- Get a list of sessions from resession and decode them
--- @param opts config telescope-resession configuration --- @param opts config telescope-resession configuration
--- @return string[] The list of decoded sessions --- @return string[] The list of decoded sessions
M.get_results = function(opts) M.get_results = function(opts)
return M.decode_sessions(M.get_sessions(), opts) return M.decode_sessions(M.get_sessions(opts), opts)
end end
return M return M