Files
nvim_windows/lua/core/autocmds.lua
2026-02-17 10:20:44 +03:00

25 lines
637 B
Lua

local group = vim.api.nvim_create_augroup("IndentFormatOnSave", { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
group = group,
callback = function(args)
local ft = vim.bo[args.buf].filetype
local indent_filetypes = {
c = true,
cpp = true,
h = true,
hpp = true,
}
if not indent_filetypes[ft] then
return
end
local view = vim.fn.winsaveview()
vim.api.nvim_buf_call(args.buf, function()
vim.cmd("silent keepjumps normal! gg=G")
end)
vim.fn.winrestview(view)
end,
})