vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI", "InsertLeave" }, { nested = true, callback = function() if vim.bo.modified and vim.bo.buftype == "" and not vim.bo.readonly and vim.fn.expand("%") ~= "" then vim.cmd("silent! write") end end, })