about summary refs log tree commit diff
path: root/fnl/nvrc/packs/cmp.fnl
diff options
context:
space:
mode:
Diffstat (limited to 'fnl/nvrc/packs/cmp.fnl')
-rw-r--r--fnl/nvrc/packs/cmp.fnl49
1 files changed, 33 insertions, 16 deletions
diff --git a/fnl/nvrc/packs/cmp.fnl b/fnl/nvrc/packs/cmp.fnl
index 616a39d..7e88eea 100644
--- a/fnl/nvrc/packs/cmp.fnl
+++ b/fnl/nvrc/packs/cmp.fnl
@@ -1,5 +1,12 @@
 (import-macros {: set!} :nvrc.macro.set)
-(local cmp (require :cmp))
+(local {: setup
+        : mapping
+        :config {: compare : disable}
+        : ConfirmBehavior
+        : visible
+        : select_next_item
+        : select_prev_item} (require :cmp))
+(local under-compare (require :cmp-under-comparator))
 (local luasnip (require :luasnip))
 
 (set! completeopt "menuone,noselect")
@@ -30,7 +37,7 @@
               :Operator "(op)"
               :TypeParameter "(tp)"})
 
-(cmp.setup {:snippet {:expand (fn [args]
+(setup {:snippet {:expand (fn [args]
                                 ((. (require :luasnip) :lsp_expand) args.body))}
             :formatting {:format (fn [entry vim-item]
                                    (set vim-item.kind
@@ -41,23 +48,33 @@
                                         (. {: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 (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace
+            :mapping {:<C-p> (mapping.select_prev_item)
+                      :<C-n> (mapping.select_next_item)
+                      :<C-d> (mapping.scroll_docs (- 4))
+                      :<C-f> (mapping.scroll_docs 4)
+                      :<C-Space> (mapping.complete)
+                      :<C-e> (mapping.close)
+                      :<up> disable
+                      :<down> disable
+                      :<CR> (mapping (mapping.confirm {:behavior ConfirmBehavior.Replace
                                                                :select false}) [:i :c])
-                      :<Tab> (cmp.mapping {:i (fn [fallback]
-                                              (if (cmp.visible) (cmp.select_next_item)
+                      :<Tab> (mapping {:i (fn [fallback]
+                                              (if (visible) (select_next_item)
                                               (luasnip.expand_or_jumpable) (luasnip.expand_or_jump)
                                               (fallback)))
-                                         :c (cmp.mapping.select_prev_item {:select true})})
-                      :<S-Tab> (cmp.mapping {:i (fn [fallback]
-                                                  (if (cmp.visible) (cmp.select_next_item)
+                                         :c (mapping.select_prev_item {:select true})})
+                      :<S-Tab> (mapping {:i (fn [fallback]
+                                                  (if (visible) (select_next_item)
                                                   (luasnip.jumpable -1) (luasnip.jump -1)
                                                   (fallback)))
-                                             :c (cmp.mapping.select_prev_item {:select true})})}
+                                             :c (mapping.select_prev_item {:select true})})}
             :sources [{:name :nvim_lsp}
-                      {:name :nvim_lsp_signature_help}]})
+                      {:name :nvim_lsp_signature_help}]
+            :sorting {:comparators [compare.offset
+                                    compare.exact
+                                    compare.score
+                                    under-compare.under
+                                    compare.kind
+                                    compare.sort_text
+                                    compare.length
+                                    compare.order]}})