about summary refs log tree commit diff
path: root/fnl/nvrc/packs/cmp.fnl
blob: 0f36592ae74d72031bfce4d6e7520cd692314dbc (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
55
56
57
(import-macros {: set!} :nvrc.macro.set)
(local cmp (require :cmp))

(set! completeopt "menuone,noselect")

(local icons {:Text "(t)"
              :Method "(m)"
              :Function "(f)"
              :Constructor "(cs)"
              :Field "(s)"
              :Variable "(v)"
              :Class "(c)"
              :Interface "(i)"
              :Module "(m)"
              :Property "(p)"
              :Unit "(u)"
              :Value "(v)"
              :Enum "(e)"
              :Keyword "(k)"
              :Snippet "(sn)"
              :Color "(co)"
              :File "(fi)"
              :Reference "(r)"
              :Folder "(fl)"
              :EnumMember "(em)"
              :Constant "(cn)"
              :Struct "(s)"
              :Event "(ev)"
              :Operator "(op)"
              :TypeParameter "(tp)"})

(cmp.setup {
            :formatting {:format (fn [entry vim-item]
                                   (set vim-item.kind
                                        (string.format "%s %s"
                                                       (. icons vim-item.kind)
                                                       vim-item.kind))
                                   (set vim-item.menu
                                        (. {:nvim_lsp "[LSP]"}
                                           entry.source.name))
                                   vim-item)}
            :mapping {:<C-p> (cmp.mapping.select_prev_item)
                      :<C-n> (cmp.mapping.select_next_item)
                      :<C-d> (cmp.mapping.scroll_docs (- 4))
                      :<C-f> (cmp.mapping.scroll_docs 4)
                      :<C-Space> (cmp.mapping.complete)
                      :<C-e> (cmp.mapping.close)
                      :<CR> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace
                                                  :select true})
                      :Tab (fn [fallback]
                             (if (cmp.visible) (cmp.select_next_item)"")
                             (fallback))
                      :<S-Tab> (fn [fallback]
                                 (if (cmp.visible) (cmp.select_next_item)"")
                                 (fallback))}
            :sources [{:name :nvim_lsp}
                      {:name :nvim_lsp_signature_help}]})