fix blink.cmp

main
maye 2025-05-20 18:56:46 +08:00
parent afb9b59235
commit 3f78f99244
4 changed files with 28 additions and 59 deletions

View File

@ -1,11 +1,11 @@
{ {
"blink.cmp": { "branch": "main", "commit": "c2bac7fba61e66dfc513cf63daa98546c86a617c" }, "blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" },
"conform.nvim": { "branch": "master", "commit": "a4bb5d6c4ae6f32ab13114e62e70669fa67745b9" }, "conform.nvim": { "branch": "master", "commit": "a4bb5d6c4ae6f32ab13114e62e70669fa67745b9" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"gitsigns.nvim": { "branch": "main", "commit": "ee0606259ee5d5dd40398be26755048e8965086e" }, "gitsigns.nvim": { "branch": "main", "commit": "ee0606259ee5d5dd40398be26755048e8965086e" },
"gruvbox.nvim": { "branch": "main", "commit": "00e38a379bab3389e187b3953566d67d494dfddd" }, "gruvbox.nvim": { "branch": "main", "commit": "00e38a379bab3389e187b3953566d67d494dfddd" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"mason.nvim": { "branch": "main", "commit": "1aceba8bc158b5aaf90649077cad06744bc23ac4" }, "mason.nvim": { "branch": "main", "commit": "9eaedb864cdadc29c6eb7d761a6c0d8aee26c91b" },
"nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" },
"nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" }, "nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" },
"nvim-tree.lua": { "branch": "master", "commit": "be5b788f2dc1522c73fb7afad9092331c8aebe80" }, "nvim-tree.lua": { "branch": "master", "commit": "be5b788f2dc1522c73fb7afad9092331c8aebe80" },

View File

@ -1,4 +1,9 @@
local lspconfig = require("lspconfig")
if require("commons").tools.is_version_gte_0_11() then if require("commons").tools.is_version_gte_0_11() then
-- vim.lsp.config("*", {
-- capabilities = require("blink.cmp").get_lsp_capabilities(),
-- root_markers = { ".git" },
-- })
for _, server in pairs(require("commons").servers) do for _, server in pairs(require("commons").servers) do
local ok, settings = pcall(require, "lsp." .. server) local ok, settings = pcall(require, "lsp." .. server)
if ok then if ok then
@ -13,11 +18,12 @@ if require("commons").tools.is_version_gte_0_11() then
virtual_text = true, virtual_text = true,
}) })
else else
local lsp = require("lspconfig") local capabilities = require('blink.cmp').get_lsp_capabilities()
for _, server in pairs(require("commons").servers) do for _, server in pairs(require("commons").servers) do
local ok, settings = pcall(require, "lsp." .. server) local ok, settings = pcall(require, "lsp." .. server)
if ok then if ok then
lsp[server].setup(settings) settings.capabilities = capabilities
lspconfig[server].setup(settings)
end end
end end
end end

9
lua/lsp/lua_ls.lua Normal file
View File

@ -0,0 +1,9 @@
return {
settings = {
Lua = {
diagnostics = {
globals = {'vim'},
}
}
}
}

View File

@ -3,16 +3,12 @@ local not_enabled_filetype = { "markdown" }
---@module 'blink.cmp' ---@module 'blink.cmp'
---@type blink.cmp.Config ---@type blink.cmp.Config
local opts = { local opts = {
cmdline = { enabled = true }, keymap = { preset = "default" },
keymap = { preset = "super-tab" },
completion = { completion = {
documentation = { documentation = {
auto_show = true, auto_show = true,
treesitter_highlighting = true, treesitter_highlighting = true,
}, },
keyword = {
range = "prefix",
},
list = { list = {
selection = { selection = {
preselect = true, preselect = true,
@ -24,74 +20,32 @@ local opts = {
create_undo_point = true, create_undo_point = true,
auto_brackets = { enabled = true }, auto_brackets = { enabled = true },
}, },
menu = {
draw = {
columns = { { "label", "label_detail", gap = 1 }, { "kind_icon", "kind", gap = 1 } },
components = {
label = {
width = { max = 30, fill = true },
text = function(ctx)
return ctx.label
end,
},
label_detail = {
width = { fill = true, max = 15 },
text = function(ctx)
return ctx.label_detail
end,
},
source_name = {},
},
},
},
}, },
appearance = { appearance = {
nerd_font_variant = "mono", nerd_font_variant = "mono",
}, },
sources = { sources = {
default = { "lsp", "path", "snippets", "buffer" }, default = { "lsp", "path", "snippets", "buffer" },
providers = {
buffer = {
enabled = true,
},
snippets = {
enabled = false,
},
},
}, },
fuzzy = { fuzzy = {
implementation = "rust", implementation = "prefer_rust_with_warning",
use_frecency = false,
use_proximity = false,
max_typos = function(_)
return 0
end,
prebuilt_binaries = {
download = false,
ignore_version_mismatch = true,
},
}, },
signature = { enabled = true }, signature = { enabled = true },
} }
local setup = function(_, opts)
return opts
end
return { return {
"saghen/blink.cmp", "saghen/blink.cmp",
opts_extend = { "sources.completion.enabled_providers", "sources.compat", "sources.default" },
dependencies = { dependencies = {
"rafamadriz/friendly-snippets", "rafamadriz/friendly-snippets",
{ "saghen/blink.compat", optional = true, opts = {}, version = not vim.g.lazyvim_blink_main and "*" }, { "saghen/blink.compat", optional = true, opts = {}, version = not vim.g.lazyvim_blink_main and "*" },
}, },
event = "InsertEnter", event = "InsertEnter",
version = "*", version = "1.*",
enabled = function() enabled = function()
return not vim.tbl_contains(not_enabled_filetype, vim.bo.filetype) return not vim.tbl_contains(not_enabled_filetype, vim.bo.filetype)
and vim.bo.buftype ~= "prompt" and vim.bo.buftype ~= "prompt"
and vim.b.completion ~= false and vim.b.completion ~= false
end, end,
opts = opts, opts = opts,
config = setup, opts_extend = { "sources.completion.enabled_providers", "sources.compat", "sources.default" },
} }