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, +}