From 8a204c43e4324a3fc7fabdb752eff5989c25c865 Mon Sep 17 00:00:00 2001 From: Abdulrahman Sheikho Date: Thu, 12 Mar 2026 19:01:00 +0300 Subject: [PATCH] add-plugin: telescope-undo.nvim --- lua/plugins/telescope-undo.lua | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 lua/plugins/telescope-undo.lua diff --git a/lua/plugins/telescope-undo.lua b/lua/plugins/telescope-undo.lua new file mode 100644 index 00000000..d267eb44 --- /dev/null +++ b/lua/plugins/telescope-undo.lua @@ -0,0 +1,67 @@ +return { + 'debugloop/telescope-undo.nvim', + dependencies = { + { + 'nvim-telescope/telescope.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + }, + }, + -- lazy = true, + keys = { + { -- lazy style key map + 'su', + function() + require('telescope').extensions.undo.undo() + end, + desc = '[S]earch [U]ndo history', + }, + }, + opts = { + extensions = { + undo = { + -- side_by_side = true, + -- layout_strategy = 'flex', + mappings = { + i = { + [''] = function(buff) + return require('telescope-undo.actions').yank_additions(buff) + end, + [''] = false, + [''] = false, + -- alternative defaults, for users whose terminals do questionable things with modified + [''] = function(buff) + return require('telescope-undo.actions').yank_additions(buff) + end, + [''] = function(buff) + return require('telescope-undo.actions').yank_additions(buff) + end, + [''] = function(buff) + return require('telescope-undo.actions').yank_deletions(buff) + end, + [''] = function(buff) + return require('telescope-undo.actions').restore(buff) + end, + }, + n = { + ['y'] = function(buff) + return require('telescope-undo.actions').yank_additions(buff) + end, + ['Y'] = function(buff) + return require('telescope-undo.actions').yank_deletions(buff) + end, + ['u'] = function(buff) + return require('telescope-undo.actions').restore(buff) + end, + }, + }, + }, + }, + }, + config = function(_, opts) + -- Calling telescope's setup from multiple specs does not hurt, it will happily merge the + -- configs for us. We won't use data, as everything is in it's own namespace (telescope + -- defaults, as well as each extension). + require('telescope').setup(opts) + require('telescope').load_extension 'undo' + end, +}