feat(telescope): #7 start adding delete feature
parent
b778a4ebc4
commit
0c392ddb9f
|
|
@ -24,7 +24,9 @@ M.options = {}
|
|||
function M.setup(opts)
|
||||
M.options = vim.tbl_deep_extend("force", {}, defaults, opts or {})
|
||||
if M.options.options then
|
||||
vim.cmd('echohl WarningMsg | echom "Persisted.nvim: The `option` config variable has now been replaced by vim.o.sessionoptions" | echohl NONE')
|
||||
vim.cmd(
|
||||
'echohl WarningMsg | echom "Persisted.nvim: The `option` config variable has now been replaced by vim.o.sessionoptions" | echohl NONE'
|
||||
)
|
||||
vim.cmd('echohl WarningMsg | echom "Persisted.nvim: Please set vim.o.sessionoptions accordingly" | echohl NONE')
|
||||
end
|
||||
-- if M.options.dir then
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
local actions_state = require("telescope.actions.state")
|
||||
|
||||
local M = {}
|
||||
|
||||
---Get the selected session from Telescope
|
||||
---@return table
|
||||
local get_selected_session = function()
|
||||
return actions_state.get_selected_entry()
|
||||
end
|
||||
|
||||
---Delete the selected session from disk
|
||||
--@return string
|
||||
M.delete_session = function()
|
||||
print(get_selected_session().file_path)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -5,6 +5,8 @@ local conf = require("telescope.config").values
|
|||
local entry_display = require("telescope.pickers.entry_display")
|
||||
local action_state = require("telescope.actions.state")
|
||||
|
||||
local _actions = require("telescope._extensions.actions")
|
||||
|
||||
local function search_sessions(opts)
|
||||
local config = require("persisted.config").options
|
||||
|
||||
|
|
@ -56,7 +58,15 @@ local function search_sessions(opts)
|
|||
results = require("persisted").list(),
|
||||
entry_maker = make_entry,
|
||||
}),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
attach_mappings = function(prompt_bufnr, map)
|
||||
local refresh_sessions = function()
|
||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||
local finder = require("persisted").list()
|
||||
picker:refresh(finder, { reset_prompt = true })
|
||||
end
|
||||
|
||||
map("i", "<c-d>", _actions.delete_session)
|
||||
|
||||
actions.select_default:replace(function()
|
||||
local session = action_state.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
|
|
|
|||
Loading…
Reference in New Issue