Run the eslint language server for JavaScript, TypeScript and Vue
Drop the filetypes copied from cssls so nvim-lspconfig's defaults apply, fall back to the global eslint, and honour a project's ESLint baseline (eslint-suppressions.json) via applySuppressions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c057c995fd
commit
3fed16e0b9
1 file changed
+21
-1
@@ -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 = {
|
||||
|
||||
Reference in new issue
Block a user