2021-10-08 13:04:57 +02:00
|
|
|
(module dots.plugins.cmp
|
|
|
|
{autoload {a aniseed.core
|
|
|
|
cmp cmp}})
|
|
|
|
|
2021-10-09 13:26:38 +02:00
|
|
|
; check this for coloring maybe
|
|
|
|
; https://github.com/hrsh7th/nvim-cmp/blob/ada9ddeff71e82ad0e52c9a280a1e315a8810b9a/lua/cmp/entry.lua#L199
|
|
|
|
(defn item-formatter [item vim-item]
|
|
|
|
(let [padding (string.rep " " (- 10 (vim.fn.strwidth vim-item.abbr)))
|
|
|
|
details (?. item :completion_item :detail)]
|
|
|
|
(when details
|
|
|
|
(set vim-item.abbr (.. vim-item.abbr padding " " details))))
|
|
|
|
vim-item)
|
|
|
|
|
|
|
|
|
2021-10-08 13:04:57 +02:00
|
|
|
(cmp.setup
|
2021-10-09 13:26:38 +02:00
|
|
|
{:snippet {:expand (fn [args] ((. vim.fn :vsnip#anonymous) args.body))}
|
|
|
|
|
|
|
|
:completion {:autocomplete false}
|
|
|
|
|
2021-10-08 14:06:50 +02:00
|
|
|
:mapping {:<C-d> (cmp.mapping.scroll_docs -4)
|
2021-10-08 13:04:57 +02:00
|
|
|
:<C-f> (cmp.mapping.scroll_docs 4)
|
|
|
|
:<C-space> (cmp.mapping.complete)
|
2022-01-14 11:23:05 +01:00
|
|
|
:<esc> #(do (cmp.mapping.close) (vim.cmd "stopinsert"))
|
|
|
|
:<CR> (cmp.mapping.confirm {:select true})}
|
2021-10-09 13:26:38 +02:00
|
|
|
|
2021-10-13 08:06:20 +02:00
|
|
|
:experimental {:custom_menu true}
|
2021-10-09 13:26:38 +02:00
|
|
|
|
2021-10-08 14:20:26 +02:00
|
|
|
:sources [{:name "nvim_lsp" :priority 5}
|
|
|
|
{:name "vsnip" :priority 3}
|
2021-10-09 13:26:38 +02:00
|
|
|
{:name "nvim_lua"}
|
|
|
|
{:name "calc"}
|
|
|
|
{:name "path"}
|
2021-10-08 14:20:26 +02:00
|
|
|
{:name "crates"}]
|
2021-10-08 14:06:50 +02:00
|
|
|
;{:name "buffer"}]
|
2021-10-09 13:26:38 +02:00
|
|
|
|
|
|
|
:formatting {:format item-formatter}
|
|
|
|
|
2021-10-13 08:06:20 +02:00
|
|
|
:sorting {:comparators [#(do (if (and (= 15 ($1:get_kind)) (= 15 ($2:get_kind))) nil
|
|
|
|
(= 15 ($1:get_kind)) false
|
|
|
|
(= 15 ($2:get_kind)) true
|
|
|
|
nil)) ; 15 means "SNIPPET", see https://github.com/hrsh7th/nvim-cmp/blob/main/lua/cmp/types/lsp.lua
|
2021-10-08 14:06:50 +02:00
|
|
|
cmp.config.compare.offset
|
|
|
|
cmp.config.compare.exact
|
|
|
|
cmp.config.compare.score
|
|
|
|
cmp.config.compare.kind
|
|
|
|
cmp.config.compare.sort_text
|
|
|
|
cmp.config.compare.length
|
|
|
|
cmp.config.compare.order]}})
|
|
|
|
|
2022-01-14 11:23:05 +01:00
|
|
|
(cmp.setup.cmdline "/" {:sources [{:name :buffer}]})
|
|
|
|
|
2021-10-09 13:26:38 +02:00
|
|
|
|