From 3f78f9924415312c3e01e280885cb1aa362b54d5 Mon Sep 17 00:00:00 2001 From: maye Date: Tue, 20 May 2025 18:56:46 +0800 Subject: [PATCH] fix blink.cmp --- lazy-lock.json | 4 ++-- lua/functions/lsp.lua | 20 ++++++++++------ lua/lsp/lua_ls.lua | 9 ++++++++ lua/plugins/blink.lua | 54 ++++--------------------------------------- 4 files changed, 28 insertions(+), 59 deletions(-) create mode 100644 lua/lsp/lua_ls.lua diff --git a/lazy-lock.json b/lazy-lock.json index 622e9eb..bacc020 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -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" }, diff --git a/lua/functions/lsp.lua b/lua/functions/lsp.lua index 1db565e..4c67720 100644 --- a/lua/functions/lsp.lua +++ b/lua/functions/lsp.lua @@ -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 diff --git a/lua/lsp/lua_ls.lua b/lua/lsp/lua_ls.lua new file mode 100644 index 0000000..6db7f08 --- /dev/null +++ b/lua/lsp/lua_ls.lua @@ -0,0 +1,9 @@ +return { + settings = { + Lua = { + diagnostics = { + globals = {'vim'}, + } + } + } +} diff --git a/lua/plugins/blink.lua b/lua/plugins/blink.lua index d2b6604..167cdf1 100644 --- a/lua/plugins/blink.lua +++ b/lua/plugins/blink.lua @@ -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" }, }