fix: remove redundant autocmd for formatter

This commit is contained in:
Tomas Mirchev 2025-10-26 03:35:28 +02:00
parent 63e81da490
commit a4b5accc05
2 changed files with 9 additions and 11 deletions

View File

@ -47,6 +47,7 @@ au({ 'WinEnter', 'InsertLeave' }, {
au({ 'WinLeave', 'InsertEnter' }, { au({ 'WinLeave', 'InsertEnter' }, {
group = group, group = group,
callback = function() callback = function()
-- Keep it on NvimTree to show current file
if vim.bo.filetype == 'NvimTree' then if vim.bo.filetype == 'NvimTree' then
return return
end end

View File

@ -293,13 +293,16 @@ end
function M.lint.setup() function M.lint.setup()
vim.api.nvim_create_autocmd({ 'BufReadPre', 'BufNewFile' }, { vim.api.nvim_create_autocmd({ 'BufReadPre', 'BufNewFile' }, {
group = M.group, group = M.group,
once = true,
callback = function() callback = function()
local lint = require('lint') local lint = require('lint')
lint.linters_by_ft = (M.general and M.general.linters_by_ft) or {} lint.linters_by_ft = (M.general and M.general.linters_by_ft) or {}
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
group = vim.api.nvim_create_augroup('language-manager.lint', { clear = true }), group = vim.api.nvim_create_augroup('language-manager.lint', { clear = true }),
callback = function() callback = function()
lint.try_lint() if vim.bo.modifiable then
lint.try_lint()
end
end, end,
}) })
end, end,
@ -307,16 +310,10 @@ function M.lint.setup()
end end
function M.format.setup() function M.format.setup()
vim.api.nvim_create_autocmd('BufWritePre', { require('conform').setup({
group = M.group, formatters_by_ft = (M.general and M.general.formatters_by_ft) or {},
once = true, default_format_opts = { stop_after_first = true, lsp_format = 'fallback' },
callback = function() format_on_save = { timeout_ms = 500 },
require('conform').setup({
format_on_save = { timeout_ms = 500, lsp_format = 'fallback' },
default_format_opts = { stop_after_first = true },
formatters_by_ft = (M.general and M.general.formatters_by_ft) or {},
})
end,
}) })
end end