summaryrefslogtreecommitdiff
path: root/fnl/config/cmp.fnl
blob: f7e9c7bd5c24fd5fb6ac7d52f5d382e2be5475ad (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
;; Configuration for completion plugin.
(module config.cmp
  {autoload {nvim aniseed.nvim
             util util}})

(local luasnip (let [(ok? luasnip) util.load-plugin :luasnip]
  (when ok?
    (do
      (require :luasnip/loaders/from_vscode).lazy_load)
      luasnip)))

(local lspkind (let [(ok? lspkind) util.load-plugin :lspkind]
  (when ok?
    lspkind)))

(lspkind.init)

(defn- snip [args]
  (luasnip.lsp_expand args.body)

(let [(ok? cmp) util.load-plugin :cmp]
  (when ok?
    (cmp.setup {
      :snippet {
          :expand snip}
      :mapping {
          "<C-k>" (cmp.mapping.select_prev_item)
          "<C-j>" (cmp.mapping.select_next_item)}
      :sources [
        {:name "nvim_lsp"}
        {:name "nvim_lua"}
        {:name "luasnip"}
        {:name "buffer" :keyword_length 4}
        {:name "path" :keyword_length 6}]
      :formatting {:format (lspkind.cmp_format {
          :with_text true
          :menu {
              :buffer "[Buf]"
              :nvim_lsp "[LSP]"
              :nvim_lua "[api]"
              :path "[path]"
              :luasnip "[Snip]"
            }})}
      :documentation {
        :border [ "╭" "─" "╮" "│" "╯" "─" "╰" "│" ]}
      :experimental {
        :ghost_text false
        :native_menu false}})))