From 2afce0278ebfd7baf0031a57a1b196003af523b7 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Sat, 21 Dec 2024 22:58:51 +0100 Subject: [PATCH] Set keybindings and confirmation --- lua/telescope/_extensions/telescope_knot.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/telescope/_extensions/telescope_knot.lua b/lua/telescope/_extensions/telescope_knot.lua index f9264fc..06565cc 100644 --- a/lua/telescope/_extensions/telescope_knot.lua +++ b/lua/telescope/_extensions/telescope_knot.lua @@ -66,11 +66,14 @@ telescope_knot.zones = function(opts) local record = _filter_records(entry, records) actions.close(prompt_bufnr) local buffer = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_name(buffer, entry.value) vim.api.nvim_buf_set_lines(buffer, 0, 0, false, record) local width = vim.api.nvim_win_get_width(0) local height = vim.api.nvim_win_get_height(0) - 10 local _ = vim.api.nvim_open_win(buffer, true, { relative = 'win', bufpos = { 0, 0 }, width = width, height = height, border = 'rounded' }) + vim.api.nvim_set_keymap("n", "q", "bd", {}) + vim.api.nvim_buf_set_keymap(buffer, "c", "w", "", {}) vim.api.nvim_create_autocmd({ "BufWinLeave" }, { buffer = buffer, callback = function(_) @@ -101,7 +104,10 @@ telescope_knot.zones = function(opts) " -r" .. cleanold.rtype .. " -d" .. cleanold.data .. table.concat(changed, " ") - log.info(vim.fn.system(command)) + local choice = vim.fn.confirm("Update record?", "&Yes\n&No", 2) + if choice == 1 then + log.info(vim.fn.system(command)) + end end end end