aboutsummaryrefslogtreecommitdiffstats
path: root/lua/plugins/undotree.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/plugins/undotree.lua')
-rw-r--r--lua/plugins/undotree.lua40
1 files changed, 33 insertions, 7 deletions
diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua
index 3f96d83..fd105c5 100644
--- a/lua/plugins/undotree.lua
+++ b/lua/plugins/undotree.lua
@@ -1,11 +1,37 @@
return {
- "mbbill/undotree",
- lazy = false, -- needs to be explicitly set, because of the keys property
- keys = {
- {
- "<leader>u",
- vim.cmd.UndotreeToggle,
- desc = "Toggle undotree",
+ {
+ "mbbill/undotree",
+ cmd = "UndotreeToggle",
+ keys = {
+ -- [U]ndo [T]ree
+ { "<leader>uT", "<cmd>UndotreeToggle<cr>", desc = "Undo Tree Toggle" },
},
+ init = function()
+ -- Persist undo, refer https://github.com/mbbill/undotree#usage
+ local undodir = vim.fn.expand("~/.cache/undodir")
+
+ if vim.fn.has("persistent_undo") == 1 then
+ if vim.fn.isdirectory(undodir) == 0 then
+ os.execute("mkdir -p " .. undodir)
+ end
+
+ vim.opt.undodir = undodir
+ vim.opt.undofile = true
+ end
+
+ -- set layout style to 2, let g:undotree_WindowLayout = 2
+ vim.g.undotree_WindowLayout = 2
+ end,
+ },
+ {
+ "folke/edgy.nvim",
+ optional = true,
+ opts = function(_, opts)
+ opts.left = opts.left or {}
+ table.insert(opts.left, {
+ title = "Undo Tree",
+ ft = "undotree",
+ })
+ end,
},
}