Skip to content

Commit

Permalink
fix(eslint): only run EslintFixAll on buffers where eslint is attached
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Mar 10, 2023
1 parent aa8bae0 commit f1dbd09
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/lazyvim/plugins/extras/linting/eslint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ return {
setup = {
eslint = function()
vim.api.nvim_create_autocmd("BufWritePre", {
command = "EslintFixAll",
callback = function(event)
if require("lspconfig.util").get_active_client_by_name(event.buf, "eslint") then
vim.cmd("EslintFixAll")
end
end,
})
end,
},
Expand Down

1 comment on commit f1dbd09

@ooloth
Copy link

@ooloth ooloth commented on f1dbd09 Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement on the original suggestion! It's much better to condition this autocmd on eslint being active instead of it the buffer being a JS/TS file.

Please sign in to comment.