summaryrefslogtreecommitdiff
path: root/fnl/plugins/lsp/keymaps.fnl
blob: 3e4614978a7d21982a8d13762ed1ac23f566388e (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
;; Key mappings for lsp.

(local mappings
       [[:n :gD "<cmd>lua vim.lsp.buf.declaration()<CR>" {:desc :Declaration}]
        [:n
         :gd
         "<cmd>Telescope lsp_definitions theme=dropdown<cr>"
         {:desc :Definition}]
        [:n
         :gI
         "<cmd>Telescope lsp_implementations theme=dropdown<cr>"
         {:desc :Implementation}]
        [:n
         :gr
         "<cmd>Telescope lsp_references theme=dropdown<cr>"
         {:desc :References}]
        [:n
         :gl
         "<cmd>lua vim.diagnostic.open_float()<CR>"
         {:desc :Diagnostics}]
        [:n
         :gS
         "<cmd>Telescope lsp_document_symbols theme=dropdown<cr>"
         {:desc "Document Symbols"}]
        [:n
         :gj
         "<cmd>Telescope diagnostics theme=dropdown<cr>"
         {:desc "Telescope Diagnostics"}]
        [:n
         :gw
         "<cmd>Telescope lsp_dynamic_workspace_symbols theme=dropdown<cr>"
         {:desc "Workspace Symbols"}]
        [:n
         :gE
         "<cmd>Telescope lsp_type_definitions theme=dropdown<cr>"
         {:desc "Workspace Symbols"}]
        [:n :gs "<cmd>lua vim.lsp.buf.signature_help()<CR>" {:desc :Signature}]
        [:n :gh "<cmd>lua vim.lsp.buf.code_action()<cr>" {:desc "Code Action"}]
        [:n :gb "<cmd>lua vim.lsp.codelens.run()<cr>" {:desc "Code Lens"}]
        [:n :K "<cmd>lua vim.lsp.hover()<cr>" {:desc "Hover documentation"}]
        [:n :<leader>li :<cmd>LspInfo<cr> {:desc "Lsp Info"}]])

(fn on-attach [buffer]
  (let [opts {:noremap true :silent true : buffer}]
    (each [_ mapping (ipairs mappings)]
      (match mapping
        [mode key cmd desc]
        (vim.keymap.set mode key cmd (vim.tbl_extend :force opts desc))))))

{: on-attach}