diff --git a/lua/neorg/modules/core/esupports/indent/module.lua b/lua/neorg/modules/core/esupports/indent/module.lua index 795e9b5991..072c66d9f4 100644 --- a/lua/neorg/modules/core/esupports/indent/module.lua +++ b/lua/neorg/modules/core/esupports/indent/module.lua @@ -315,8 +315,17 @@ module.on_event = function(event) local indentkeys = "o,O,*,*" .. lib.when(module.config.public.format_on_enter, ",*", "") - .. lib.when(module.config.public.format_on_escape, ",*", "") vim.api.nvim_buf_set_option(event.buffer, "indentkeys", indentkeys) + + if module.config.public.format_on_escape then + vim.api.nvim_create_autocmd("InsertLeave", { + pattern = "*.norg", + callback = function(_ev) + vim.bo.undolevels = vim.bo.undolevels + vim.cmd("normal! ==") + end, + }) + end end end