You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kickstart.nvim/lua/plugins/eslint.lua

42 lines
1.4 KiB
Lua

return {
{
"neovim/nvim-lspconfig",
-- other settings removed for brevity
opts = {
---@type lspconfig.options
servers = {
eslint = {
settings = {
-- helps eslint find the eslintrc when it's placed in a subfolder instead of the cwd root
workingDirectory = { mode = "auto" },
},
},
},
setup = {
eslint = function()
require("lazyvim.util").on_attach(function(client)
if client.name == "eslint" then
client.server_capabilities.documentFormattingProvider = true
elseif client.name == "tsserver" then
client.server_capabilities.documentFormattingProvider = false
end
end)
end,
-- eslint = function()
-- vim.api.nvim_create_autocmd("BufWritePre", {
-- callback = function(event)
-- local client = vim.lsp.get_active_clients({ bufnr = event.buf, name = "eslint" })[1]
-- if client then
-- local diag = vim.diagnostic.get(event.buf, { namespace = vim.lsp.diagnostic.get_namespace(client.id) })
-- if #diag > 0 then
-- vim.cmd("EslintFixAll")
-- end
-- end
-- end,
-- })
-- end,
},
},
},
}