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" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"gitsigns.nvim": { "branch": "main", "commit": "ee0606259ee5d5dd40398be26755048e8965086e" },
"gruvbox.nvim": { "branch": "main", "commit": "00e38a379bab3389e187b3953566d67d494dfddd" },
"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-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" },
"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
-- vim.lsp.config("*", {
-- capabilities = require("blink.cmp").get_lsp_capabilities(),
-- root_markers = { ".git" },
-- })
for _, server in pairs(require("commons").servers) do
local ok, settings = pcall(require, "lsp." .. server)
if ok then
@ -13,11 +18,12 @@ if require("commons").tools.is_version_gte_0_11() then
virtual_text = true,
})
else
local lsp = require("lspconfig")
for _,server in pairs(require("commons").servers) do
local ok,settings = pcall(require,"lsp."..server)
if ok then
lsp[server].setup(settings)
end
end
local capabilities = require('blink.cmp').get_lsp_capabilities()
for _, server in pairs(require("commons").servers) do
local ok, settings = pcall(require, "lsp." .. server)
if ok then
settings.capabilities = capabilities
lspconfig[server].setup(settings)
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'
---@type blink.cmp.Config
local opts = {
cmdline = { enabled = true },
keymap = { preset = "super-tab" },
keymap = { preset = "default" },
completion = {
documentation = {
auto_show = true,
treesitter_highlighting = true,
},
keyword = {
range = "prefix",
},
list = {
selection = {
preselect = true,
@ -24,74 +20,32 @@ local opts = {
create_undo_point = 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 = {
nerd_font_variant = "mono",
},
sources = {
default = { "lsp", "path", "snippets", "buffer" },
providers = {
buffer = {
enabled = true,
},
snippets = {
enabled = false,
},
},
},
fuzzy = {
implementation = "rust",
use_frecency = false,
use_proximity = false,
max_typos = function(_)
return 0
end,
prebuilt_binaries = {
download = false,
ignore_version_mismatch = true,
},
implementation = "prefer_rust_with_warning",
},
signature = { enabled = true },
}
local setup = function(_, opts)
return opts
end
return {
"saghen/blink.cmp",
opts_extend = { "sources.completion.enabled_providers", "sources.compat", "sources.default" },
dependencies = {
"rafamadriz/friendly-snippets",
{ "saghen/blink.compat", optional = true, opts = {}, version = not vim.g.lazyvim_blink_main and "*" },
},
event = "InsertEnter",
version = "*",
version = "1.*",
enabled = function()
return not vim.tbl_contains(not_enabled_filetype, vim.bo.filetype)
and vim.bo.buftype ~= "prompt"
and vim.b.completion ~= false
end,
opts = opts,
config = setup,
opts_extend = { "sources.completion.enabled_providers", "sources.compat", "sources.default" },
}