mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-03-10 09:27:25 +00:00
fix(eslint): remove old 0.10 code
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user