neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
10.01k stars 2.04k forks source link

Eslint LSP Does Not Display Errors and Warnings on v4.9.0 or after #3149

Closed Drew-Daniels closed 2 months ago

Drew-Daniels commented 2 months ago

Description

Thanks for this plugin! I use this for development everyday.

I use mason.nvim and mason-lspconfig.nvim to manage my language servers.

I have been able to update the eslint language server consistently, up until the v4.9.0 release.

eslint.config.mjs:

import globals from "globals";
import pluginJs from "@eslint/js";

export default [
  { languageOptions: { globals: globals.browser },
    rules: {
      "no-undef": "off",
      "no-unused-vars": "off",
    },
  },
  pluginJs.configs.recommended,
];

When I upgrade to v4.9.0, and open a JavaScript file, I can see that the eslint server is running, but I stop getting eslint warnings and errors.

image

image

When I downgrade back to v4.8.0, and see I start getting eslint warnings and errors again:

image

❯ nvim --version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1713773202

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.5/share/nvim"

Run :checkhealth for more info

nvim-lspconfig version as in lazy-lock.json:

  "nvim-lspconfig": { "branch": "master", "commit": "a27179f56c6f98a4cdcc79ee2971b514815a4940" },
local lspconfig = require("lspconfig")

local servers = {
    "eslint",
    "emmet_language_server",
    "jsonls",
    "html",
    "bashls",
    "clangd",
    "cssmodules_ls",
    "docker_compose_language_service",
    "dockerls",
    "emmet_language_server",
    "yamlls",
    "marksman",
    "cucumber_language_server",
    "tailwindcss",
    "terraformls",
    "solargraph",
    "sqlls",
    "vimls",
    "prismals",
    "pylsp",
    "graphql",
    -- turning off for now: https://github.com/nrwl/nx-console/issues/2019
    -- "nxls",
}
for _, lsp in ipairs(servers) do
    lspconfig[lsp].setup({
        capabilities = capabilities,
    })
end

lspconfig.cssls.setup({
    capabilities = capabilities,
    settings = {
        css = {
            validate = true,
            lint = {
                unknownAtRules = "ignore",
            },
        },
        scss = {
            validate = true,
            lint = {
                unknownAtRules = "ignore",
            },
        },
        less = {
            validate = true,
            lint = {
                unknownAtRules = "ignore",
            },
        },
    },
})

lspconfig.lua_ls.setup({
    capabilities = capabilities,
    settings = {
        Lua = {
            diagnostics = {
                globals = { "vim" },
            },
        },
    },
})

lspconfig.typos_lsp.setup({
    capabilities = capabilities,
    filetypes = { "markdown", "norg" },
})

-- https://www.npbee.me/posts/deno-and-typescript-in-a-monorepo-neovim-lsp
---Specialized root pattern that allows for an exclusion
---@param opt { root: string[], exclude: string[] }
---@return fun(file_name: string): string | nil
local function root_pattern_exclude(opt)
    local lsputil = require("lspconfig.util")

    return function(fname)
        local excluded_root = lsputil.root_pattern(opt.exclude)(fname)
        local included_root = lsputil.root_pattern(opt.root)(fname)

        if excluded_root then
            return nil
        else
            return included_root
        end
    end
end
glepnir commented 2 months ago

you upgrade eslint version then you got it not work. so what's the problem of this plugin ?

Drew-Daniels commented 2 months ago

The problem is that this plugin doesn't work when I upgrade eslint,so I think there might need to be changes so that it does?

dyllandry commented 1 month ago

@Drew-Daniels Thanks for reporting this. I have this issue too, and downgrading the eslint lang server to 4.8.0 worked for me too.

Drew-Daniels commented 1 month ago

@dyllandry Totally! Glad it helped. Also, FWIW, I was able to upgrade eslint to the latest version and get LSP diagnositics as expected by updating my LSP config to:

require("mason-lspconfig").setup({
    ensure_installed = {
-- ...
        "eslint",
-- ...
    },
})
-- ... 
lspconfig.eslint.setup({
    capabilities = capabilities,
    settings = {
        workingDirectories = { mode = "auto" },
    experimental = {
      useFlatConfig = false,
    }
    },
})

My guess is that this was silently failing when eslint v4.9.0 was used, but after that, I started getting errors logged in neovim about the change from nested to flat configs, at which point I updated my config to the above 🤷🏻

jonathanmorris180 commented 4 weeks ago

Just chiming in here to report another incidence of this—eslint did not work for me using v4.10.0.

To solve, run :MasonInstall eslint-lsp@4.8.0.