aboutsummaryrefslogtreecommitdiffstats
path: root/lua/plugins/undotree.lua
blob: fd105c57d2d5aa1e189962e4d40f7a198f85725e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
return {
  {
    "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,
  },
}