diff --git a/lua/custom/lspconfig.lua b/lua/custom/lspconfig.lua index b26ca73..13d7c8c 100644 --- a/lua/custom/lspconfig.lua +++ b/lua/custom/lspconfig.lua @@ -124,8 +124,28 @@ setup_server("pyright", { filetypes = { "py" } }) setup_server("html", { filetypes = { "html" } }) setup_server("cssls", { filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" } }) +-- nvim-lspconfig's own filetypes (javascript, typescript, vue, the *react +-- variants, svelte, ...) - the server uses the project's node_modules eslint +-- and its config, like ALE does in ~/repos/vim. nodePath is the fallback +-- for projects without one: the global eslint (npm root -g), which the +-- server doesn't look in on its own. +-- +-- applySuppressions honours a project's ESLint baseline (eslint-suppressions.json, +-- e.g. rcc's), which the server otherwise ignores. Only set when that file +-- exists: eslint before 9.24 doesn't know the option and refuses to start. +-- nvim-lspconfig's own before_init (workspaceFolder) still runs first. +local eslint_before_init = vim.lsp.config.eslint.before_init setup_server("eslint", { - filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, + settings = { nodePath = "/usr/lib/node_modules" }, + before_init = function(params, config) + if eslint_before_init then + eslint_before_init(params, config) + end + if config.root_dir and vim.uv.fs_stat(config.root_dir .. "/eslint-suppressions.json") then + config.settings.options = vim.tbl_extend("force", config.settings.options or {}, + { applySuppressions = true }) + end + end, }) setup_server("rust_analyzer", { settings = {