Merge branch 'main' into dev

This commit is contained in:
chuyanlong 2025-09-15 16:47:49 +08:00
commit cb5c4b5e81
6 changed files with 43 additions and 12 deletions

View file

@ -1,4 +1,4 @@
*LazyVim.txt* For Neovim Last change: 2025 May 12
*LazyVim.txt* For Neovim Last change: 2025 September 15
==============================================================================
Table of Contents *LazyVim-table-of-contents*

View file

@ -51,7 +51,7 @@ return {
LazyVim.lualine.status(LazyVim.config.icons.kinds.Copilot, function()
local clients = package.loaded["copilot"] and LazyVim.lsp.get_clients({ name = "copilot", bufnr = 0 }) or {}
if #clients > 0 then
local status = require("copilot.api").status.data.status
local status = require("copilot.status").data.status
return (status == "InProgress" and "pending") or (status == "Warning" and "error") or "ok"
end
end)

View file

@ -109,7 +109,7 @@ return {
if not opts.keymap["<Tab>"] then
if opts.keymap.preset == "super-tab" then -- super-tab
opts.keymap["<Tab>"] = {
require("blink.cmp.keymap.presets")["super-tab"]["<Tab>"][1],
require("blink.cmp.keymap.presets").get("super-tab")["<Tab>"][1],
LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
"fallback",
}

View file

@ -114,11 +114,7 @@ return {
{
"linux-cultist/venv-selector.nvim",
branch = "regexp", -- Use this branch for the new version
cmd = "VenvSelect",
enabled = function()
return LazyVim.has("telescope.nvim")
end,
opts = {
settings = {
options = {
@ -126,7 +122,7 @@ return {
},
},
},
-- Call config for python files and load the cached venv automatically
-- Call config for Python files and load the cached venv automatically
ft = "python",
keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv", ft = "python" } },
},

View file

@ -53,7 +53,7 @@ function M.has(buffer, method)
method = method:find("/") and method or "textDocument/" .. method
local clients = LazyVim.lsp.get_clients({ bufnr = buffer })
for _, client in ipairs(clients) do
if client.supports_method(method) then
if client:supports_method(method) then
return true
end
end

View file

@ -1,16 +1,51 @@
---@class lazyvim.util.lsp
local M = {}
---@alias lsp.Client.filter {id?: number, bufnr?: number, name?: string, method?: string, filter?:fun(client: lsp.Client):boolean}
---@alias lsp.Client.filter {id?: number, bufnr?: number, name?: string, method?: string, filter?:fun(client: vim.lsp.Client):boolean}
--- Neovim 0.11 uses a lua class for clients, while older versions use a table.
--- Wraps older style clients to be compatible with the new style.
---@param client vim.lsp.Client
---@return vim.lsp.Client
local function wrap(client)
local meta = getmetatable(client)
if meta and meta.request then
return client
end
---@diagnostic disable-next-line: undefined-field
if client.wrapped then
return client
end
local methods = { "request", "supports_method", "cancel_request", "notify" }
-- old style
return setmetatable({ wrapped = true }, {
__index = function(_, k)
if k == "supports_method" then
-- supports_method doesn't support the bufnr argument
return function(_, method)
return client[k](method)
end
end
if vim.tbl_contains(methods, k) then
return function(_, ...)
return client[k](...)
end
end
return client[k]
end,
})
end
---@param opts? lsp.Client.filter
function M.get_clients(opts)
local ret = {} ---@type vim.lsp.Client[]
if vim.lsp.get_clients then
ret = vim.lsp.get_clients(opts)
ret = vim.tbl_map(wrap, ret)
else
---@diagnostic disable-next-line: deprecated
ret = vim.lsp.get_active_clients(opts)
ret = vim.tbl_map(wrap, ret)
if opts and opts.method then
---@param client vim.lsp.Client
ret = vim.tbl_filter(function(client)
@ -29,7 +64,7 @@ function M.on_attach(on_attach, name)
local buffer = args.buf ---@type number
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client and (not name or client.name == name) then
return on_attach(client, buffer)
return on_attach(wrap(client), buffer)
end
end,
})
@ -75,7 +110,7 @@ function M._check_methods(client, buffer)
for method, clients in pairs(M._supports_method) do
clients[client] = clients[client] or {}
if not clients[client][buffer] then
if client.supports_method and client.supports_method(method, { bufnr = buffer }) then
if client.supports_method and client:supports_method(method, { bufnr = buffer }) then
clients[client][buffer] = true
vim.api.nvim_exec_autocmds("User", {
pattern = "LspSupportsMethod",