Skip to content

Commit 5b115db

Browse files
committed
refactor: migrating from nvim.cmp to blink.cmp
1 parent 5f9ca31 commit 5b115db

File tree

11 files changed

+160
-300
lines changed

11 files changed

+160
-300
lines changed

lazy-lock.json

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
11
{
2-
"LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" },
3-
"cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" },
4-
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
5-
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
6-
"codecompanion.nvim": { "branch": "main", "commit": "1c0f609faa3336971dffb62453353e1c28ed1f04" },
7-
"conform.nvim": { "branch": "master", "commit": "db8a4a9edb217067b1d7a2e0362c74bfe9cc944d" },
8-
"copilot.lua": { "branch": "master", "commit": "30321e33b03cb924fdcd6a806a0dc6fa0b0eafb9" },
2+
"blink.cmp": { "branch": "main", "commit": "49f211fe5d729df53df4c042d7c3464cf47d199e" },
3+
"codecompanion.nvim": { "branch": "main", "commit": "ccbaf205d2d842dbef4c9ad9532576cf08fd4b1f" },
4+
"conform.nvim": { "branch": "master", "commit": "f9ef25a7ef00267b7d13bfc00b0dea22d78702d5" },
5+
"copilot.lua": { "branch": "master", "commit": "0da7ebc11bf63fe0591f664430266dfc87d77dbf" },
96
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
107
"fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" },
118
"flutter-tools.nvim": { "branch": "main", "commit": "8edcdabfe982c77482ebde2ba3f46f2adc677e64" },
12-
"fzf": { "branch": "master", "commit": "923c3a814de39ff906d675834af634252b3d2b3f" },
9+
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
10+
"fzf": { "branch": "master", "commit": "dac5b6fde1cb6242492e8d27cbea162e37517be0" },
1311
"gitsigns.nvim": { "branch": "main", "commit": "7010000889bfb6c26065e0b0f7f1e6aa9163edd9" },
1412
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
1513
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" },
16-
"mason-tool-installer.nvim": { "branch": "main", "commit": "5639d58a3d11ff7c05c8e31e159bfedae55d7961" },
14+
"mason-tool-installer.nvim": { "branch": "main", "commit": "98767d37f8e5255a5111fc1e3163232d4dc07bda" },
1715
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
18-
"mini.ai": { "branch": "main", "commit": "6e01c0e5a15554852546fac9853960780ac52ed4" },
16+
"mini.ai": { "branch": "main", "commit": "978ffc65c6b513fde9ef075326d34d89197f1ea5" },
1917
"mini.bracketed": { "branch": "main", "commit": "0ec65567ffde0ad4d94d794d55f3b627203b496a" },
2018
"mini.comment": { "branch": "main", "commit": "264b8a63edd5a9a41d5361a1d52c13131c3c51a2" },
2119
"mini.extra": { "branch": "main", "commit": "7725a82b4d9c0acdc370385b9c04bb0791017230" },
22-
"mini.files": { "branch": "main", "commit": "0a396f5ca5516a07959ae2c00667e1a26c20f0ea" },
20+
"mini.files": { "branch": "main", "commit": "b6c9cb5f5ebbd9014097cd1296baf74c92b656aa" },
2321
"mini.hipatterns": { "branch": "main", "commit": "fbf1e2195fdd65cf1bc970316c28098257728868" },
2422
"mini.icons": { "branch": "main", "commit": "ec61af6e606fc89ee3b1d8f2f20166a3ca917a36" },
2523
"mini.jump": { "branch": "main", "commit": "1fb371cfdcb314c5faa272976f23514f264bd755" },
26-
"mini.pairs": { "branch": "main", "commit": "1a3e73649c0eaef2f6c48ce1e761c6f0a7c11918" },
24+
"mini.pairs": { "branch": "main", "commit": "b90e36aa5ca5e0d825e77ad67aac22214a4d9096" },
2725
"mini.splitjoin": { "branch": "main", "commit": "efe24ba54f9623cb05698355981ec05278976788" },
28-
"mini.statusline": { "branch": "main", "commit": "83209bfbca156f9e4a5ec47a2a8ce1e5ce26311d" },
29-
"mini.surround": { "branch": "main", "commit": "f90069c7441a5fb04c3de42eacf93e16b64dd3eb" },
26+
"mini.statusline": { "branch": "main", "commit": "ec3adf7813b7604275dd4a28433e9c9610b70f1b" },
27+
"mini.surround": { "branch": "main", "commit": "c92d262deae79545b7674b2069332116461a85f3" },
28+
"nordic.nvim": { "branch": "main", "commit": "8627750ece357e9670f9e69853091f7fbb8d6523" },
3029
"nvim-bqf": { "branch": "main", "commit": "ebb6d2689e4427452180f17c53f29f7e460236f1" },
31-
"nvim-cmp": { "branch": "main", "commit": "1e1900b0769324a9675ef85b38f99cca29e203b3" },
3230
"nvim-dap": { "branch": "master", "commit": "6a5bba0ddea5d419a783e170c20988046376090d" },
3331
"nvim-dap-view": { "branch": "main", "commit": "8fff34699823c354815891d7081972ef5166a31e" },
34-
"nvim-lint": { "branch": "master", "commit": "936197073214c26a347fb933c9459c8766376b23" },
35-
"nvim-lspconfig": { "branch": "master", "commit": "185b2af444b27d6541c02d662b5b68190e5cf0c4" },
36-
"nvim-treesitter": { "branch": "master", "commit": "98a3fdd5d9807948be6f27a916a5b88a92383670" },
37-
"nvim-treesitter-context": { "branch": "master", "commit": "83ded3bbff8bc13abc9704bf1c5e426f3ba343c4" },
32+
"nvim-lint": { "branch": "master", "commit": "93b8040115c9114dac1047311763bef275e752dc" },
33+
"nvim-lspconfig": { "branch": "master", "commit": "c3cb73a75bbf58a82764c563c17bcf87bdd89595" },
34+
"nvim-treesitter": { "branch": "master", "commit": "da5825bf70cc2ea7eacd1e60c32c07baf19adeba" },
35+
"nvim-treesitter-context": { "branch": "master", "commit": "93b29a32d5f4be10e39226c6b796f28d68a8b483" },
3836
"nvim-treesitter-textobjects": { "branch": "master", "commit": "9937e5e356e5b227ec56d83d0a9d0a0f6bc9cad4" },
39-
"onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" },
40-
"overseer.nvim": { "branch": "master", "commit": "d95931e9e8cc4429819c8bbae395da00a6800d1e" },
37+
"overseer.nvim": { "branch": "master", "commit": "72c68aab0358c92f451168b704c411c4a3e3410e" },
4138
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
42-
"render-markdown.nvim": { "branch": "main", "commit": "125258ac5bccd21651505d78dbd6120906243749" },
39+
"render-markdown.nvim": { "branch": "main", "commit": "c91fa46fc8d79f5577beac70a459f30ec17a60c2" },
4340
"snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" },
4441
"trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" },
4542
"vim-fugitive": { "branch": "master", "commit": "4a745ea72fa93bb15dd077109afbb3d1809383f2" },

lua/core/keymaps.lua

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
local map = vim.keymap.set
22

33
map("n", "q:", "<nop>", { noremap = true })
4-
map("n", "Q", "<nop>", { noremap = true })
5-
map("n", "q", "<nop>", { noremap = true })
64

7-
map({ "n", "v", "x" }, "d", '"_d', { desc = "Delete without yanking", noremap = true })
8-
map({ "n", "v", "x" }, "D", '"_D', { desc = "Delete without yanking", noremap = true })
95
map({ "n", "v", "x" }, "c", '"_c', { desc = "Change without yanking", noremap = true })
106
map({ "n", "v", "x" }, "C", '"_C', { desc = "Change without yanking", noremap = true })
117

@@ -27,7 +23,8 @@ map({ "i", "c" }, "<C-k>", "<Up>", { desc = "Move up" })
2723
map("n", "<C-d>", "<C-d>zz", { desc = "Scroll down and keep the cursor at the center" })
2824
map("n", "<C-u>", "<C-u>zz", { desc = "Scroll up and keep the cursor at the center" })
2925

30-
map({ "x", "n" }, "<C-s>", "<Cmd>w<CR><Esc>", { desc = "Save File" })
26+
map({ "i", "x", "n", "s" }, "<C-s>", "<Cmd>w<CR><Esc>", { desc = "Save File", noremap = true })
27+
map({ "i", "x", "n", "s" }, "<CS-s>", "<Cmd>noautocmd w<CR><Esc>", { desc = "Save File (noautocmd)", noremap = true })
3128

3229
map("n", "<S-Up>", "<Cmd>resize +2<CR>", { desc = "Increase window height" })
3330
map("n", "<S-Down>", "<Cmd>resize -2<CR>", { desc = "Decrease window height" })

lua/core/options.lua

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
1-
local opt = vim.opt
2-
31
vim.g.mapleader = " "
4-
vim.o.termguicolors = true
52

63
vim.g.customsnippetspath = os.getenv("SNIPPETS_PATH")
74

8-
opt.laststatus = 3
9-
opt.showmode = false
10-
11-
opt.number = true
12-
opt.relativenumber = true
13-
opt.wrap = false
14-
opt.ruler = false
15-
opt.cursorline = true
16-
opt.signcolumn = "auto:1-3"
17-
opt.list = true
18-
opt.listchars = { tab = "» ", trail = "·", nbsp = "" }
19-
opt.mouse = "a"
20-
21-
opt.wildmode = "longest:full,full"
22-
opt.completeopt = "menu,menuone"
23-
opt.conceallevel = 2
24-
25-
opt.clipboard = "unnamedplus"
26-
27-
opt.expandtab = true
28-
opt.shiftwidth = 2
29-
opt.smartindent = true
30-
opt.tabstop = 2
31-
opt.softtabstop = 2
32-
33-
opt.fillchars = { eob = " " }
34-
opt.ignorecase = true
35-
opt.smartcase = true
36-
opt.splitbelow = true
37-
opt.splitright = true
38-
opt.timeoutlen = 400
39-
opt.updatetime = 250 -- Required by CursorHold, CursorHoldI autocmds
40-
41-
opt.swapfile = false
42-
opt.undofile = true
43-
opt.undolevels = 10000
44-
45-
opt.inccommand = "split"
46-
47-
opt.scrolloff = 10
5+
vim.opt.laststatus = 3
6+
vim.opt.showmode = false
7+
8+
vim.opt.number = true
9+
vim.opt.relativenumber = true
10+
vim.opt.wrap = false
11+
vim.opt.ruler = false
12+
vim.opt.cursorline = true
13+
-- vim.opt.signcolumn = "auto:1-3"
14+
vim.opt.list = true
15+
vim.opt.listchars = { extends = "", precedes = "", tab = "» ", trail = "·", nbsp = "" }
16+
vim.opt.mouse = "a"
17+
18+
vim.opt.wildmode = "longest:full,full"
19+
vim.opt.completeopt = "menu,menuone"
20+
vim.opt.conceallevel = 2
21+
22+
vim.opt.clipboard = "unnamedplus"
23+
24+
vim.opt.expandtab = true
25+
vim.opt.shiftwidth = 2
26+
vim.opt.smartindent = true
27+
vim.opt.tabstop = 2
28+
vim.opt.softtabstop = 2
29+
30+
vim.opt.fillchars = { eob = " ", fold = " " }
31+
vim.opt.ignorecase = true
32+
vim.opt.smartcase = true
33+
vim.opt.splitbelow = true
34+
vim.opt.splitright = true
35+
vim.opt.timeoutlen = 400
36+
vim.opt.updatetime = 250 -- Required by CursorHold, CursorHoldI autocmds
37+
38+
vim.opt.swapfile = false
39+
vim.opt.undofile = true
40+
vim.opt.undolevels = 10000
41+
42+
vim.opt.inccommand = "split"
43+
vim.opt.winborder = "single"
44+
45+
vim.opt.scrolloff = 10
4846
-- opt.winblend = 10
4947
-- opt.pumblend = 10
5048
-- opt.pumheight = 10
49+
50+
vim.o.foldenable = true
51+
vim.o.foldlevel = 99
52+
vim.o.foldtext = ""

lua/plugins/cmp.lua

Lines changed: 40 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,59 @@
11
return {
22
{
3-
"hrsh7th/nvim-cmp",
4-
event = "InsertEnter",
3+
"saghen/blink.cmp",
4+
version = "*",
55
dependencies = {
6-
"hrsh7th/cmp-nvim-lsp",
7-
"hrsh7th/cmp-path",
8-
"saadparwaiz1/cmp_luasnip",
9-
{
10-
"L3MON4D3/LuaSnip",
11-
build = "make install_jsregexp",
12-
opts = {
13-
history = true,
14-
updateevents = "TextChanged,TextChangedI",
6+
{ "rafamadriz/friendly-snippets" },
7+
},
8+
opts = {
9+
sources = {
10+
default = { "lsp", "path", "snippets" },
11+
},
12+
fuzzy = {
13+
implementation = "prefer_rust_with_warning",
14+
sorts = {
15+
"exact",
16+
"score",
17+
"sort_text",
1518
},
16-
config = function(_, opts)
17-
require("luasnip").config.set_config(opts)
18-
require("luasnip.loaders.from_vscode").lazy_load({ paths = vim.g.customsnippetspath })
19-
require("luasnip.loaders.from_snipmate").lazy_load({ paths = vim.g.customsnippetspath })
20-
21-
vim.api.nvim_create_autocmd("InsertLeave", {
22-
callback = function()
23-
if
24-
require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
25-
and not require("luasnip").session.jump_active
26-
then
27-
require("luasnip").unlink_current()
28-
end
29-
end,
30-
})
31-
end,
3219
},
33-
},
34-
opts = function()
35-
local cmp = require("cmp")
36-
local types = require("cmp.types")
37-
38-
return {
39-
sources = cmp.config.sources({
40-
{ name = "nvim_lsp" },
41-
}, {
42-
{ name = "luasnip" },
43-
{ name = "path" },
44-
}),
45-
snippet = {
46-
expand = function(args)
47-
require("luasnip").lsp_expand(args.body)
48-
end,
20+
keymap = { preset = "default" },
21+
cmdline = { enabled = false },
22+
completion = {
23+
accept = {
24+
auto_brackets = { enabled = false },
4925
},
50-
sorting = {
51-
priority_weight = 2,
52-
comparators = {
53-
function(entry1, entry2)
54-
local _, entry1_under = entry1.completion_item.label:find("^_+")
55-
local _, entry2_under = entry2.completion_item.label:find("^_+")
56-
entry1_under = entry1_under or 0
57-
entry2_under = entry2_under or 0
58-
if entry1_under > entry2_under then
59-
return false
60-
elseif entry1_under < entry2_under then
61-
return true
62-
end
63-
end,
64-
function(entry1, entry2)
65-
local kind_scores = {
66-
Property = 1,
67-
Variable = 2,
68-
Snippet = 3,
69-
Field = 4,
70-
Method = 5,
71-
Constructor = 6,
72-
Function = 7,
73-
Class = 8,
74-
Interface = 9,
75-
Module = 10,
76-
Unit = 11,
77-
Value = 12,
78-
Enum = 13,
79-
Keyword = 14,
80-
Color = 16,
81-
File = 17,
82-
Reference = 18,
83-
Folder = 19,
84-
EnumMember = 20,
85-
Constant = 21,
86-
Struct = 22,
87-
Event = 23,
88-
Operator = 24,
89-
TypeParameter = 25,
90-
Text = 26,
91-
}
92-
local kind1 = types.lsp.CompletionItemKind[entry1:get_kind()]
93-
local kind2 = types.lsp.CompletionItemKind[entry2:get_kind()]
94-
95-
local diff = kind_scores[kind1] - kind_scores[kind2]
96-
97-
if diff == 0 then
98-
return nil
99-
end
100-
101-
return diff < 0
102-
end,
103-
cmp.config.compare.locality,
104-
cmp.config.compare.exact,
105-
cmp.config.compare.order,
106-
},
26+
list = {
27+
selection = { preselect = true, auto_insert = false },
10728
},
108-
-- experimental = {
109-
-- ghost_text = true,
110-
-- },
111-
mapping = cmp.mapping.preset.insert({
112-
["<C-n>"] = cmp.mapping.select_next_item(),
113-
["<C-p>"] = cmp.mapping.select_prev_item(),
114-
["<C-b>"] = cmp.mapping.scroll_docs(-4),
115-
["<C-f>"] = cmp.mapping.scroll_docs(4),
116-
["<C-y>"] = cmp.mapping.confirm({ select = true }),
117-
["<C-Space>"] = cmp.mapping.complete(),
118-
["<C-e>"] = cmp.mapping.close(),
119-
120-
["<C-l>"] = cmp.mapping(function(fallback)
121-
if require("luasnip").expand_or_locally_jumpable() then
122-
require("luasnip").expand_or_jump()
123-
else
124-
fallback()
125-
end
126-
end, { "i", "s" }),
127-
128-
["<C-h>"] = cmp.mapping(function(fallback)
129-
if require("luasnip").locally_jumpable(-1) then
130-
require("luasnip").jump(-1)
131-
else
132-
fallback()
133-
end
134-
end, { "i", "s" }),
135-
136-
["<Esc>"] = cmp.mapping(function(fallback)
137-
if cmp.visible() then
138-
cmp.abort()
139-
vim.cmd("stopinsert")
140-
else
141-
fallback()
142-
end
143-
end, { "i" }),
144-
}),
145-
window = {
146-
completion = {
147-
winhighlight = "Normal:NormalFloat,CursorLine:Visual",
148-
},
149-
documentation = {
150-
winhighlight = "Normal:NormalFloat,CursorLine:Visual",
151-
},
29+
menu = {
30+
draw = { treesitter = { "lsp" } },
31+
scrollbar = false,
15232
},
153-
view = {
154-
entries = {
155-
follow_cursor = true,
33+
documentation = {
34+
auto_show = true,
35+
window = {
36+
scrollbar = false,
15637
},
15738
},
158-
}
159-
end,
39+
ghost_text = { enabled = false },
40+
},
41+
signature = {
42+
enabled = true,
43+
window = {
44+
scrollbar = false,
45+
treesitter_highlighting = true,
46+
show_documentation = true,
47+
},
48+
},
49+
},
16050
},
16151
{
16252
"neovim/nvim-lspconfig",
16353
optional = true,
164-
dependencies = { "hrsh7th/cmp-nvim-lsp" },
16554
opts = function(_, opts)
16655
opts.capabilities = opts.capabilities or {}
167-
opts.capabilities.cmp = require("cmp_nvim_lsp").default_capabilities()
56+
opts.capabilities.cmp = require("blink.cmp").get_lsp_capabilities()
16857
end,
16958
},
17059
}

0 commit comments

Comments
 (0)