update for windows
This commit is contained in:
24
lua/core/autocmds.lua
Normal file
24
lua/core/autocmds.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
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,
|
||||
})
|
||||
Reference in New Issue
Block a user