about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2024-12-20 00:22:41 +0900
committersefidel <contact@sefidel.net>2024-12-20 00:22:41 +0900
commita6776b69d5082ab75ba6b1373b7cae6f4884f7b0 (patch)
tree5b77cabdd31805fa5880f09c42d1e35f1a1fe1fc
parent0634cac078ff662efa4ae73bdf344ce3fa2a090d (diff)
downloadnvimrc-a6776b69d5082ab75ba6b1373b7cae6f4884f7b0.tar.gz
nvimrc-a6776b69d5082ab75ba6b1373b7cae6f4884f7b0.zip
feat(pack)!: replace nvim-cmp with blink.cmp
-rw-r--r--fnl/nvrc/pack.fnl6
-rw-r--r--fnl/nvrc/packs/blink-cmp.fnl65
-rw-r--r--fnl/nvrc/packs/cmp.fnl79
-rw-r--r--lazy-lock.json4
4 files changed, 68 insertions, 86 deletions
diff --git a/fnl/nvrc/pack.fnl b/fnl/nvrc/pack.fnl
index bd7d0ae..9427842 100644
--- a/fnl/nvrc/pack.fnl
+++ b/fnl/nvrc/pack.fnl
@@ -44,10 +44,8 @@
 (pack! :tpope/vim-eunuch)
 (pack! :tpope/vim-sleuth)
 
-(pack! :hrsh7th/nvim-cmp {:req :cmp
-                          :event [:InsertEnter :CmdlineEnter]
-                          :dependencies [(pack :lukas-reineke/cmp-under-comparator)
-                                         (pack :hrsh7th/cmp-nvim-lsp {:after :nvim-cmp})]})
+(pack! :Saghen/blink.cmp {:req :blink-cmp
+                          :build "nix run .#build-plugin"})
 (pack! :stevearc/conform.nvim {:req :conform :cmd [:ConformInfo :ConformFormat] :keys ["gq"]})
 (pack! :numToStr/Comment.nvim {:init :Comment :lazy true})
 (pack! :ibhagwan/fzf-lua {:req :fzf :lazy true})
diff --git a/fnl/nvrc/packs/blink-cmp.fnl b/fnl/nvrc/packs/blink-cmp.fnl
new file mode 100644
index 0000000..549eb6e
--- /dev/null
+++ b/fnl/nvrc/packs/blink-cmp.fnl
@@ -0,0 +1,65 @@
+(local {: setup} (require :blink.cmp))
+
+(setup {:keymap {:<Tab> [(fn [cmp]
+                           (if (cmp.snippet_active) (cmp.accept)
+                               (cmp.select_next))) "fallback"]
+                 :<S-Tab> ["select_prev" "snippet_backward" "fallback"]
+                 :<CR> ["accept" "fallback"]
+                 :<Backspace> ["cancel" "fallback"]
+                 :<C-Space> ["show" "show_documentation" "hide_documentation"]
+                 :<C-e> ["hide" "fallback"]
+                 :<C-d> ["scroll_documentation_down" "fallback"]
+                 :<C-f> ["scroll_documentation_up" "fallback"]
+                 :<A-1> [(fn [cmp] (cmp.accept {:index 1}))]
+                 :<A-2> [(fn [cmp] (cmp.accept {:index 2}))]
+                 :<A-3> [(fn [cmp] (cmp.accept {:index 3}))]
+                 :<A-4> [(fn [cmp] (cmp.accept {:index 4}))]
+                 :<A-5> [(fn [cmp] (cmp.accept {:index 5}))]
+                 :<A-6> [(fn [cmp] (cmp.accept {:index 6}))]
+                 :<A-7> [(fn [cmp] (cmp.accept {:index 7}))]
+                 :<A-8> [(fn [cmp] (cmp.accept {:index 8}))]
+                 :<A-9> [(fn [cmp] (cmp.accept {:index 9}))]
+                 :<A-0> [(fn [cmp] (cmp.accept {:index 10}))]
+                 :<A-=> ["select_next" "fallback"]
+                 :<A--> ["select_prev" "fallback"]
+                 :<Up> ["select_prev" "fallback"]
+                 :<Down> ["select_next" "fallback"]}
+        :appearance {:kind_icons {:Text "(t)"
+                                  :Method "(f)"
+                                  :Function "(f)"
+                                  :Constructor "(C)"
+                                  :Field "(s)"
+                                  :Variable "(v)"
+                                  :Property "(p)"
+                                  :Class "(C)"
+                                  :Interface "(I)"
+                                  :Struct "(S)"
+                                  :Module "(M)"
+                                  :Unit "(U)"
+                                  :Value "(V)"
+                                  :Enum "(e)"
+                                  :EnumMember "(e)"
+                                  :Keyword "(k)"
+                                  :Constant "(c)"
+                                  :Snippet "(x)"
+                                  :Color "(t)"
+                                  :File "(t)"
+                                  :Reference "(*)"
+                                  :Folder "(t)"
+                                  :Event "(e)"
+                                  :Operator "(o)"
+                                  :TypeParameter "(k)"}}
+        :sources {:default [:lsp :path :snippets :buffer]}
+        :signature {:enabled true} ; experimental signature support
+        :fuzzy {:prebuilt_binaries {:download false}}
+        :completion {:list {:selection :auto_insert}
+                     :menu {:draw {:treesitter [:lsp]
+                                   :columns [
+                                             {1 :item_idx}
+                                             {1 :label 2 :label_description :gap 1}
+                                             {1 :kind_icon :gap 1 2 :kind}
+                                             {1 :source_name}]
+                                   :components {:item_idx {:text (fn [ctx] (tostring ctx.idx))
+                                                           :highlight :BlinkCmpItemIdx}
+                                                :label_description {:width {:max 10}}
+                                                :source_name {:text (fn [ctx] (.. "[" ctx.source_name "]"))}}}}}})
diff --git a/fnl/nvrc/packs/cmp.fnl b/fnl/nvrc/packs/cmp.fnl
deleted file mode 100644
index 6fea0d1..0000000
--- a/fnl/nvrc/packs/cmp.fnl
+++ /dev/null
@@ -1,79 +0,0 @@
-(import-macros {: set!} :nvrc.macro.set)
-(local {: setup
-        : mapping
-        :config {: compare : disable}
-        : ConfirmBehavior
-        : visible
-        : select_next_item
-        : select_prev_item} (require :cmp))
-(local under-compare (require :cmp-under-comparator))
-(local clangd-score (require :clangd_extensions.cmp_scores))
-
-(set! completeopt "menuone,noselect")
-
-(local icons {:Text "(t)"
-              :Method "(m)"
-              :Function "(f)"
-              :Constructor "(C)"
-              :Field "(s)"
-              :Variable "(v)"
-              :Class "(C)"
-              :Interface "(i)"
-              :Module "(m)"
-              :Property "(p)"
-              :Unit "(u)"
-              :Value "(v)"
-              :Enum "(e)"
-              :EnumMember "(e)"
-              :Keyword "(k)"
-              :Snippet "(S)"
-              :Color "(R)"
-              :Reference "(r)"
-              :Constant "(c)"
-              :Struct "(s)"
-              :Event "(e)"
-              :Operator "(o)"
-              :TypeParameter "(T)"
-              :File "(F)"
-              :Folder "(F)"
-              })
-
-(setup {:snippet {:expand (fn [args]
-                                (vim.snippet.expand args.body))}
-            :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> (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> (mapping {:i (fn [fallback]
-                                              (if (visible) (select_next_item)
-                                              (vim.snippet.active {:direction 1}) (vim.snippet.jump 1)
-                                              (fallback)))})
-                      :<S-Tab> (mapping {:i (fn [fallback]
-                                                  (if (visible) (select_next_item)
-                                                  (vim.snippet.active {:direction -1}) (vim.snippet.jump -1)
-                                                  (fallback)))})}
-            :sources [{:name :nvim_lsp}]
-            :sorting {:comparators [compare.offset
-                                    compare.exact
-                                    clangd-score
-                                    compare.score
-                                    under-compare.under
-                                    compare.kind
-                                    compare.sort_text
-                                    compare.length
-                                    compare.order]}})
diff --git a/lazy-lock.json b/lazy-lock.json
index 5b872d7..a33a7e3 100644
--- a/lazy-lock.json
+++ b/lazy-lock.json
@@ -1,8 +1,7 @@
 {
   "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
+  "blink.cmp": { "branch": "main", "commit": "46eb5f3fd3dba0a3bb3d026fb2b7462f4a0656b7" },
   "clangd_extensions.nvim": { "branch": "main", "commit": "8f7b72100883e0e34400d9518d40a03f21e4d0a6" },
-  "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" },
-  "cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" },
   "conform.nvim": { "branch": "master", "commit": "f4e8837878fc5712d053ba3091a73d27d96a09e2" },
   "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
   "editorconfig.nvim": { "branch": "master", "commit": "5b9e303e1d6f7abfe616ce4cc8d3fffc554790bf" },
@@ -16,7 +15,6 @@
   "mini.indentscope": { "branch": "main", "commit": "da9af64649e114aa79480c238fd23f6524bc0903" },
   "neogit": { "branch": "master", "commit": "6691c4efcd8dad313e344c49057f05db7d91fd25" },
   "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" },
-  "nvim-cmp": { "branch": "main", "commit": "3403e2e9391ed0a28c3afddd8612701b647c8e26" },
   "nvim-colorizer.lua": { "branch": "master", "commit": "4acf88d31b3a7a1a7f31e9c30bf2b23c6313abdb" },
   "nvim-dap": { "branch": "master", "commit": "567da83810dd9da32f9414d941bc6848715fc102" },
   "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" },