fix(eslint): remove old 0.10 code

This commit is contained in:
Folke Lemaitre
2025-09-17 07:14:22 +02:00
parent 732b063c30
commit 919c9e5d09

View File

@@ -10,7 +10,7 @@ return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
-- other settings removed for brevity -- other settings removed for brevity
opts = { opts = {
---@type lspconfig.options ---@type table<string, vim.lsp.Config>
servers = { servers = {
eslint = { eslint = {
settings = { settings = {
@@ -26,10 +26,6 @@ return {
return return
end end
local function get_client(buf)
return vim.lsp.get_clients({ name = "eslint", bufnr = buf })[1]
end
local formatter = LazyVim.lsp.formatter({ local formatter = LazyVim.lsp.formatter({
name = "eslint: lsp", name = "eslint: lsp",
primary = false, primary = false,
@@ -37,24 +33,6 @@ return {
filter = "eslint", filter = "eslint",
}) })
-- Use EslintFixAll on Neovim < 0.10.0
if not pcall(require, "vim.lsp._dynamic") then
formatter.name = "eslint: EslintFixAll"
formatter.sources = function(buf)
local client = get_client(buf)
return client and { "eslint" } or {}
end
formatter.format = function(buf)
local client = get_client(buf)
if client then
local diag = vim.diagnostic.get(buf, { namespace = vim.lsp.diagnostic.get_namespace(client.id) })
if #diag > 0 then
vim.cmd("EslintFixAll")
end
end
end
end
-- register the formatter with LazyVim -- register the formatter with LazyVim
LazyVim.format.register(formatter) LazyVim.format.register(formatter)
end, end,