feat(nvim): use blink.cmp

This commit is contained in:
2026-02-01 09:25:51 +08:00
parent e327d6acaf
commit a1d873cc30
7 changed files with 78 additions and 153 deletions

View File

@@ -1,25 +0,0 @@
M = {
check_ts = true,
ts_config = {
lua = { "string", "source" },
javascript = { "string", "template_string" },
},
fast_wrap = {
map = "<M-e>",
chars = { "{", "[", "(", '"', "'" },
pattern = [=[[%'%"%)%>%]%)%}%,]]=],
end_key = "$",
keys = "qwertyuiopzxcvbnmasdfghjkl",
check_comma = true,
highlight = "Search",
highlight_grey = "Comment",
},
}
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local ok, cmp = pcall(require, "cmp")
if ok then
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
end
return M

View File

@@ -1,64 +1,33 @@
local cmp = require("cmp")
--- @module "blink.cmp"
--- @type blink.cmp.Config
M = {
window = {
completion = {
border = "rounded",
scrollbar = "",
},
documentation = {
border = "rounded",
scrollbar = "",
keymap = {
-- <Tab> to accept
preset = "super-tab",
},
appearance = {
nerd_font_variant = "mono",
},
completion = {
-- By default, you may press `<c-space>` to show the documentation.
-- Optionally, set `auto_show = true` to show the documentation after a delay.
documentation = { auto_show = true, auto_show_delay_ms = 1000 },
},
sources = {
default = { "lsp", "path", "snippets", "lazydev" },
providers = {
lazydev = { module = "lazydev.integrations.blink", score_offset = 100 },
},
},
formatting = {
format = require("lspkind").cmp_format({
mode = "symbol",
maxwidth = 50,
ellipsis_char = "...",
}),
snippets = { preset = "luasnip" },
-- See :h blink-cmp-config-fuzzy for more information
fuzzy = {
implementation = "lua",
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<Escape>"] = cmp.mapping.abort(),
["<Tab>"] = cmp.mapping.confirm({ select = true }),
["<Up>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, {
"i",
"s",
}),
["<Down>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, {
"i",
"s",
}),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
}, {
{ name = "buffer" },
}),
-- Shows a signature help window while you type arguments for a function
signature = { enabled = true },
}
vim.o.wildmenu = true
vim.o.pumheight = 10
return M

View File

@@ -1,3 +0,0 @@
M = {}
return M

View File

@@ -85,12 +85,15 @@ local servers = {
-- keep-sorted end
}
local capabilities = require("cmp_nvim_lsp").default_capabilities()
capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
local capabilities = {
textDocument = {
foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
},
},
}
capabilities = require("blink.cmp").get_lsp_capabilities(capabilities)
for server, config in pairs(servers) do
config["capabilities"] = capabilities
vim.lsp.config(server, config)

View File

@@ -69,7 +69,7 @@ local plugins = {
},
{
"neovim/nvim-lspconfig",
dependencies = { "hrsh7th/cmp-nvim-lsp" },
dependencies = { "saghen/blink.cmp" },
event = "VeryLazy",
config = function()
require("plugins.lsp.lspconfig")
@@ -117,7 +117,10 @@ local plugins = {
{
"MysticalDevil/inlay-hints.nvim",
event = "LspAttach",
dependencies = { "neovim/nvim-lspconfig" },
dependencies = {
"neovim/nvim-lspconfig",
"onsails/lspkind.nvim",
},
opts = {},
},
{
@@ -128,27 +131,31 @@ local plugins = {
end,
},
{
"L3MON4D3/LuaSnip",
event = "InsertEnter",
dependencies = { { "rafamadriz/friendly-snippets", lazy = true } },
build = "make install_jsregexp",
config = function()
require("luasnip").setup(require("plugins.cmp.luasnip"))
end,
},
{
"hrsh7th/nvim-cmp",
"saghen/blink.cmp",
event = "VeryLazy",
build = "cargo build --release",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
"hrsh7th/cmp-path",
"onsails/lspkind.nvim",
{
"L3MON4D3/LuaSnip",
event = "InsertEnter",
dependencies = { { "rafamadriz/friendly-snippets", lazy = true } },
build = "make install_jsregexp",
config = function()
require("luasnip").setup(require("plugins.cmp.luasnip"))
end,
},
{
"folke/lazydev.nvim",
ft = "lua",
opts = {
library = {
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
},
event = "InsertEnter",
config = function()
require("cmp").setup(require("plugins.cmp.cmp"))
require("blink.cmp").setup(require("plugins.cmp.cmp"))
end,
},
{
@@ -159,10 +166,7 @@ local plugins = {
{
"windwp/nvim-autopairs",
event = "InsertEnter",
dependencies = { "hrsh7th/nvim-cmp" },
config = function()
require("nvim-autopairs").setup(require("plugins.autopairs"))
end,
opts = {},
},
{
"akinsho/bufferline.nvim",
@@ -207,7 +211,7 @@ local plugins = {
},
},
{
"ggandor/leap.nvim",
"https://codeberg.org/andyg/leap.nvim",
dependencies = { "tpope/vim-repeat" },
config = function()
vim.keymap.set({ "n", "x", "o" }, "s", "<Plug>(leap)")