aboutsummaryrefslogtreecommitdiffstats
path: root/lua/plugins/aerial.lua
blob: f8bc139fe4fa4ebedc4261be7179ed4a84431280 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- Silent keymap option
local opts = { silent = true }

return {
  {
    "folke/edgy.nvim",
    optional = true,
    opts = function(_, opts)
      opts.right = opts.right or {}
      table.insert(opts.right, "aerial")
      table.insert(opts.right, {
        title = "hurl.nvim",
        ft = "hurl-nvim",
        size = { width = 0.5 },
      })

    end,
  },
  {
    "stevearc/aerial.nvim",
    keys = {
      { "<leader>ta", "<cmd>AerialToggle<cr>", desc = "AerialToggle" },
    },
    config = function()
      local status_ok, aerial = pcall(require, "aerial")
      if not status_ok then
        return
      end

      aerial.setup({
        -- optionally use on_attach to set keymaps when aerial has attached to a buffer
        on_attach = function(bufnr)
          -- Jump forwards/backwards with '{' and '}'
          vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr })
          vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr })

          vim.keymap.set("n", "<leader>fi", "<cmd>Telescope aerial<CR>", opts)
        end,
      })

      local tele_status_ok, telescope = pcall(require, "telescope")
      if not tele_status_ok then
        return
      end

      -- Define a custom command to open aerial with telescope
      vim.keymap.set("n", "<leader>fi", "<cmd>Telescope aerial<CR>", {
        desc = "Telescope Aerial",
      })

      telescope.load_extension("aerial")
    end,
  },
}