fix(format): eslint should respect autoformat (#897)

This commit is contained in:
Mike Duminy
2023-06-08 07:48:34 +02:00
committed by GitHub
parent 0731f08ee4
commit 2ec4da7fa5
2 changed files with 9 additions and 0 deletions

View File

@ -16,6 +16,11 @@ return {
eslint = function()
vim.api.nvim_create_autocmd("BufWritePre", {
callback = function(event)
if not require("lazyvim.plugins.lsp.format").enabled() then
-- exit early if autoformat is not enabled
return
end
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) })