fix(lspconfig): remove all references to lspconfig. Closes #6426

This commit is contained in:
Folke Lemaitre 2025-09-15 20:42:10 +02:00
parent 167d39b2be
commit 23b9cdeb34
No known key found for this signature in database
GPG key ID: 9B52594D560070AB
7 changed files with 44 additions and 85 deletions

View file

@ -60,28 +60,22 @@ return {
keys = { keys = {
{ "<leader>ch", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" }, { "<leader>ch", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
}, },
root_dir = function(bufnr, ondir) root_markers = {
local root_directory = function(fname) ".clangd",
return require("lspconfig.util").root_pattern( ".clang-tidy",
"Makefile", ".clang-format",
"configure.ac", "compile_commands.json",
"configure.in", "compile_flags.txt",
"config.h.in", "configure.ac", -- AutoTools
"meson.build", "Makefile",
"meson_options.txt", "configure.ac",
"build.ninja" "configure.in",
)(fname) or require("lspconfig.util").root_pattern( "config.h.in",
"compile_commands.json", "meson.build",
"compile_flags.txt" "meson_options.txt",
)(fname) or require("lspconfig.util").find_git_ancestor(fname) "build.ninja",
end ".git",
if type(bufnr) == "string" then },
return root_directory(bufnr)
else
local fname = vim.api.nvim_buf_get_name(bufnr)
ondir(root_directory(fname))
end
end,
capabilities = { capabilities = {
offsetEncoding = { "utf-16" }, offsetEncoding = { "utf-16" },
}, },

View file

@ -91,9 +91,7 @@ return {
table.insert(cmd, string.format("--jvm-arg=-javaagent:%s", lombok_jar)) table.insert(cmd, string.format("--jvm-arg=-javaagent:%s", lombok_jar))
end end
return { return {
-- How to find the root dir for a given filename. The default comes from root_dir = vim.fs.root(0, vim.lsp.config.jdtls.root_markers),
-- lspconfig which provides a function specifically for java projects.
root_dir = LazyVim.lsp.get_raw_config("jdtls").default_config.root_dir,
-- How to find the project name for a given root dir. -- How to find the project name for a given root dir.
project_name = function(root_dir) project_name = function(root_dir)

View file

@ -26,17 +26,15 @@ return {
"reason", "reason",
"dune", "dune",
}, },
root_dir = function(fname) root_markers = {
return require("lspconfig.util").root_pattern( "*.opam",
"*.opam", "esy.json",
"esy.json", "package.json",
"package.json", ".git",
".git", "dune-project",
"dune-project", "dune-workspace",
"dune-workspace", "*.ml",
"*.ml" },
)(fname)
end,
}, },
}, },
}, },

View file

@ -65,11 +65,7 @@ return {
opts = { opts = {
servers = { servers = {
r_language_server = { r_language_server = {
root_dir = function(fname) root_markers = { "DESCRIPTION", "NAMESPACE", ".Rbuildignore" },
return require("lspconfig.util").root_pattern("DESCRIPTION", "NAMESPACE", ".Rbuildignore")(fname)
or require("lspconfig.util").find_git_ancestor(fname)
or vim.loop.os_homedir()
end,
}, },
}, },
}, },

View file

@ -28,11 +28,10 @@ return {
}, },
setup = { setup = {
tailwindcss = function(_, opts) tailwindcss = function(_, opts)
local tw = LazyVim.lsp.get_raw_config("tailwindcss")
opts.filetypes = opts.filetypes or {} opts.filetypes = opts.filetypes or {}
-- Add default filetypes -- Add default filetypes
vim.list_extend(opts.filetypes, tw.default_config.filetypes) vim.list_extend(opts.filetypes, vim.lsp.config.tailwindcss.filetypes)
-- Remove excluded filetypes -- Remove excluded filetypes
--- @param ft string --- @param ft string

View file

@ -228,15 +228,22 @@ return {
}) })
end end
if LazyVim.lsp.is_enabled("denols") and LazyVim.lsp.is_enabled("vtsls") then if vim.lsp.is_enabled("denols") and vim.lsp.is_enabled("vtsls") then
local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc") ---@param server string
LazyVim.lsp.disable("vtsls", is_deno) ---@param markers string[]
LazyVim.lsp.disable("denols", function(root_dir, config) local resolve = function(server, markers)
if not is_deno(root_dir) then vim.lsp.config(server, {
config.settings.deno.enable = false root_dir = function(bufnr, on_dir)
end local is_deno = vim.fs.root(bufnr, { "deno.json", "deno.jsonc" }) ~= nil
return false if is_deno == (server == "denols") then
end) local root = vim.fs.root(bufnr, markers)
return root and on_dir(root)
end
end,
})
end
resolve("denols", vim.lsp.config.denols.root_markers)
resolve("vtsls", vim.lsp.config.vtsls.root_markers)
end end
end, end,
}, },

View file

@ -107,39 +107,6 @@ function M.on_supports_method(method, fn)
}) })
end end
---@return vim.lsp.Config
function M.get_config(server)
local configs = require("lspconfig.configs")
return rawget(configs, server)
end
---@return {default_config:lspconfig.Config}
function M.get_raw_config(server)
local ok, ret = pcall(require, "lspconfig.configs." .. server)
if ok then
return ret
end
return require("lspconfig.server_configurations." .. server)
end
function M.is_enabled(server)
local c = M.get_config(server)
return c and c.enabled ~= false
end
---@param server string
---@param cond fun( root_dir, config): boolean
function M.disable(server, cond)
local util = require("lspconfig.util")
local def = M.get_config(server)
---@diagnostic disable-next-line: undefined-field
def.document_config.on_new_config = util.add_hook_before(def.document_config.on_new_config, function(config, root_dir)
if cond(root_dir, config) then
config.enabled = false
end
end)
end
---@param opts? LazyFormatter| {filter?: (string|lsp.Client.filter)} ---@param opts? LazyFormatter| {filter?: (string|lsp.Client.filter)}
function M.formatter(opts) function M.formatter(opts)
opts = opts or {} opts = opts or {}