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

@@ -17,24 +17,4 @@ vim.lsp.config("nixd", {
},
})
return {
{
"folke/lazydev.nvim",
ft = "lua",
opts = {
library = {
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
{
"hrsh7th/nvim-cmp",
opts = function(_, opts)
opts.sources = opts.sources or {}
table.insert(opts.sources, {
name = "lazydev",
group_index = 0,
})
end,
},
}
return {}

View File

@@ -1,44 +1,41 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" },
"blink.cmp": { "branch": "main", "commit": "f9e855c4d96e1264f7c818844f5a0166ad48c212" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"gitsigns.nvim": { "branch": "main", "commit": "abf82a65f185bd54adc0679f74b7d6e1ada690c9" },
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" },
"gitsigns.nvim": { "branch": "main", "commit": "1ce96a464fdbc24208e24c117e2021794259005d" },
"glance.nvim": { "branch": "master", "commit": "bf86d8b79dce808e65fdb6e9269d0b4ed6d2eefc" },
"guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" },
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
"inlay-hints.nvim": { "branch": "master", "commit": "12c48937702906f67dfbd7f64b1c0d8861635506" },
"inlay-hints.nvim": { "branch": "master", "commit": "11be32be3761c6263df2311afb6baa0de0863967" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" },
"leap.nvim": { "branch": "main", "commit": "f19d43590c4b6d31188ee1ea2954d2b7558a9e11" },
"lspkind.nvim": { "branch": "master", "commit": "dbac5149fb5fb1b642266ff268b1e0f4ebac9293" },
"leap.nvim": { "branch": "main", "commit": "d7316deae68dc93d6957020cdda6d7bb399218fb" },
"lspkind.nvim": { "branch": "master", "commit": "c7274c48137396526b59d86232eabcdc7fed8a32" },
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
"noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" },
"nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" },
"nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-lspconfig": { "branch": "master", "commit": "419b082102fa813739588dd82e19a8b6b2442855" },
"nvim-lspconfig": { "branch": "master", "commit": "66fd02ad1c7ea31616d3ca678fa04e6d0b360824" },
"nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" },
"nvim-osc52": { "branch": "main", "commit": "04cfaba1865ae5c53b6f887c3ca7304973824fb2" },
"nvim-tmux-navigation": { "branch": "main", "commit": "4898c98702954439233fdaf764c39636681e2861" },
"nvim-tree.lua": { "branch": "master", "commit": "5757bcf0447d22d8f78826bc5c59b28da2824c3b" },
"nvim-tree.lua": { "branch": "master", "commit": "037d89e60fb01a6c11a48a19540253b8c72a3c32" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef" },
"nvim-web-devicons": { "branch": "master", "commit": "803353450c374192393f5387b6a0176d0972b848" },
"outline.nvim": { "branch": "main", "commit": "1967ef50036b0b1eac4977aeede55915a741afe0" },
"nvim-web-devicons": { "branch": "master", "commit": "746ffbb17975ebd6c40142362eee1b0249969c5c" },
"outline.nvim": { "branch": "main", "commit": "ead1820d49c8e79ce89cab1c2c318981b695c9d2" },
"pest.vim": { "branch": "master", "commit": "7cfcb43f824e74d13dfe631359fff2ec23836a77" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "d6b802552cbe7d643a3b6b31f419c248d1f1e220" },
"render-markdown.nvim": { "branch": "main", "commit": "c54380dd4d8d1738b9691a7c349ecad7967ac12e" },
"render-markdown.nvim": { "branch": "main", "commit": "48b4175dbca8439d30c1f52231cbe5a712c8f9d9" },
"ripgrep": { "branch": "master", "commit": "0a88cccd5188074de96f54a4b6b44a63971ac157" },
"telescope.nvim": { "branch": "master", "commit": "0d8b6eaa0b5ae6bb3d9785f7a3ba4a4c6c1b1af2" },
"telescope.nvim": { "branch": "master", "commit": "ad7d9580338354ccc136e5b8f0aa4f880434dcdc" },
"todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" },
"tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" },
"tree-sitter-nu": { "branch": "main", "commit": "4c149627cc592560f77ead1c384e27ec85926407" },
"tree-sitter-nu": { "branch": "main", "commit": "bb3f533e5792260291945e1f329e1f0a779def6e" },
"trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" },
"vim-floaterm": { "branch": "master", "commit": "a11b930f55324e9b05e2ef16511fe713f1b456a7" },
"vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }

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)")