aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config/nvim/lua/plugins/init.lua
blob: 9c3c20a76993850a7e1c83136f1932aadc24614a (plain) (blame)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
return {
  { "nvim-lua/plenary.nvim", branch = "master", lazy = true },
  {
    "iamcco/markdown-preview.nvim",
    cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
    build = "cd app && yarn install",
    ft = "markdown",
  },
  {
    "rmagatti/auto-session",
    lazy = false,
    opts = function()
      -- Convert the cwd to a simple file name
      local function get_cwd_as_name()
        local dir = vim.fn.getcwd(0)
        return dir:gsub("[^A-Za-z0-9]", "_")
      end
      local overseer = require("overseer")
      return {
        use_git_branch = true,
        pre_save_cmds = {
          function()
            overseer.save_task_bundle(
              get_cwd_as_name(),
              -- Passing nil will use config.opts.save_task_opts. You can call list_tasks() explicitly and
              -- pass in the results if you want to save specific tasks.
              nil,
              { on_conflict = "overwrite" } -- Overwrite existing bundle, if any
            )
          end,
        },
        -- Optionally get rid of all previous tasks when restoring a session
        pre_restore_cmds = {
          function()
            for _, task in ipairs(overseer.list_tasks({})) do
              task:dispose(true)
            end
          end,
        },
        post_restore_cmds = {
          function()
            overseer.load_task_bundle(
              get_cwd_as_name(),
              { ignore_missing = true, autostart = false }
            )
          end,
        },
        save_extra_data = function(_)
          local ok, breakpoints = pcall(require, "dap.breakpoints")
          if not ok or not breakpoints then
            return
          end

          local bps = {}
          local breakpoints_by_buf = breakpoints.get()
          for buf, buf_bps in pairs(breakpoints_by_buf) do
            bps[vim.api.nvim_buf_get_name(buf)] = buf_bps
          end
          if vim.tbl_isempty(bps) then
            return
          end
          local extra_data = {
            breakpoints = bps,
          }
          return vim.fn.json_encode(extra_data)
        end,

        restore_extra_data = function(_, extra_data)
          local json = vim.fn.json_decode(extra_data)

          if json.breakpoints then
            local ok, breakpoints = pcall(require, "dap.breakpoints")

            if not ok or not breakpoints then
              return
            end
            vim.notify("restoring breakpoints")
            for buf_name, buf_bps in pairs(json.breakpoints) do
              for _, bp in pairs(buf_bps) do
                local line = bp.line
                local opts = {
                  condition = bp.condition,
                  log_message = bp.logMessage,
                  hit_condition = bp.hitCondition,
                }
                breakpoints.set(opts, vim.fn.bufnr(buf_name), line)
              end
            end
          end
        end,
        suppressed_dirs = { "~/", "/" },
      }
    end,
  },
  {
    "aserowy/tmux.nvim",
    event = "VeryLazy",
    opts = {
      resize = {
        enable_default_keybindings = false,
      },
    },
  },
  {
    "folke/which-key.nvim",
    event = "VeryLazy",
    opts = {
      spec = {
        { "g", group = "[G]oto" },
        { "yo", group = "Toggle options" },
        { "]", group = "Navigate to next" },
        { "[", group = "Navigate to previous" },
        { "<leader>c", group = "[C]ode", mode = { "n", "x" } },
        { "<leader>d", group = "[D]ocument" },
        { "<leader>g", group = "[G]it" },
        { "<leader>h", group = "Git [H]unk", mode = { "n", "v" } },
        { "<leader>n", group = "[N]eotest" },
        { "<leader>o", group = "[O]verseer" },
        { "<leader>r", group = "[R]efactor" },
        { "<leader>s", group = "[S]earch" },
        { "<leader>w", group = "[W]orkspace" },
        { "<leader>t", group = "[T]oggle" },
      },
    },
    keys = {
      {
        "<leader>?",
        function()
          require("which-key").show({ global = false })
        end,
        desc = "Buffer Local Keymaps (which-key)",
      },
    },
  },
  {
    "stevearc/quicker.nvim",
    event = "FileType qf",
    keys = {
      {
        "<leader>tq",
        function()
          require("quicker").toggle()
        end,
        desc = "[T]oggle [Q]uickfix",
      },
      {
        "<leader>tl",
        function()
          require("quicker").toggle({ loclist = true })
        end,
        desc = "[T]oggle [L]oclist",
      },
    },
    opts = {
      keys = {
        {
          ">",
          function()
            require("quicker").expand({
              before = 2,
              after = 2,
              add_to_existing = true,
            })
          end,
          desc = "Expand quickfix context",
        },
        {
          "<",
          function()
            require("quicker").collapse()
          end,
          desc = "Collapse quickfix context",
        },
      },
    },
  },
  {
    "olimorris/codecompanion.nvim",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "ravitemer/mcphub.nvim",
    },
    keys = {
      {
        "<leader>aa",
        "<cmd>CodeCompanionActions<cr>",
        mode = { "n", "v" },
        noremap = true,
        silent = true,
        desc = "[A]I [A]ctions",
      },
      {
        "<leader>ta",
        "<cmd>CodeCompanionChat Toggle<cr>",
        mode = { "n", "v" },
        noremap = true,
        silent = true,
        desc = "[T]oggle [A]I chat",
      },
      {
        "<leader>ac",
        "<cmd>CodeCompanionChat Add<cr>",
        mode = "v",
        noremap = true,
        silent = true,
        desc = "[A]I [C]hat add",
      },
    },
    opts = {
      strategies = {
        chat = {
          adapter = "copilot",
        },
        inline = {
          adapter = "copilot",
        },
      },
      extensions = {
        mcphub = {
          callback = "mcphub.extensions.codecompanion",
          opts = {
            make_vars = true,
            make_slash_commands = true,
            show_result_in_chat = true,
          },
        },
      },
    },
  },
  {
    "stevearc/oil.nvim",
    opts = {},
    lazy = false,
  },
}