Skip to content

Commit

Permalink
feat(eslint): add function to auto-fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
asyncedd committed Jun 26, 2023
1 parent 3d314a0 commit 450d793
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lua/plugins/specs/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,22 @@ return {
nil_ls = {},
rnix = {},
},
setup = {},
setup = {
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,
},
}
end,
init = function()
Expand Down

0 comments on commit 450d793

Please sign in to comment.