summaryrefslogtreecommitdiff
path: root/lua/plugins/core/which-key.lua
blob: 3c4a95b85fe4921c2eb2ffbb9ae4683d6431ac4b (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
return {
   "folke/which-key.nvim",
   event = "VeryLazy",
   init = function()
      vim.o.timeout = true
      vim.o.timeoutlen = 300
   end,

   opts = {
      f = { name = "File" },
      t = {
         name = "Tab",
         c = { "<cmd>tabnew<cr>", "Create" },
         ["1"] = { "1gt", "1" },
         ["2"] = { "2gt", "2" },
         ["3"] = { "3gt", "3" },
         ["4"] = { "4gt", "4" },
         ["5"] = { "5gt", "5" },
         ["6"] = { "6gt", "6" },
         ["7"] = { "7gt", "7" },
         ["8"] = { "8gt", "8" },
         ["9"] = { "9gt", "9" },
      },
      b = {
         name = "Buffer",
         n = { "<cmd>BufferNext<cr>", "Next" },
         p = { "<cmd>BufferPrevious<cr>", "Previous" },
         c = { "<cmd>BufferClose<cr>", "Close" },
      },
      l = {
         name = "LSP",
         a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Action" },
         f = {
            "<cmd>lua vim.lsp.buf.format({ async = false, timeout_ms = 5000 })<cr>",
            "Format",
         },
         d = { "<cmd>lua vim.diagnostic.open_float()<cr>", "Diagnostic" },
         h = { "<cmd>lua vim.lsp.buf.hover()<cr>", "Help" },
         g = {
            name = "Go to",
            D = {
               "<cmd>lua vim.lsp.buf.declaration()<cr>",
               "Go to declaration",
            },
            d = { "<cmd>lua vim.lsp.buf.definition()<cr>", "Go to definition" },
            i = {
               "<cmd>lua vim.lsp.buf.definition()<cr>",
               "Go to implementation",
            },
         },
      },
   },

   config = function(_, opts)
      local wk = require("which-key")
      wk.register(opts, { prefix = "<leader>" })
   end,
}