add linter and formatter with it's caveats
This commit is contained in:
parent
d5234fec4c
commit
dc82115506
3 changed files with 61 additions and 1 deletions
41
lua/plugins/eslint.lua
Normal file
41
lua/plugins/eslint.lua
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue