Skip to content

Commit

Permalink
feat(indent): add new undo block before indenting upon pressing esc
Browse files Browse the repository at this point in the history
  • Loading branch information
champignoom committed Jan 2, 2024
1 parent 52de5cf commit b2d20f5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lua/neorg/modules/core/esupports/indent/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,17 @@ module.on_event = function(event)

local indentkeys = "o,O,*<M-o>,*<M-O>"
.. lib.when(module.config.public.format_on_enter, ",*<CR>", "")
.. lib.when(module.config.public.format_on_escape, ",*<Esc>", "")
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

Expand Down

0 comments on commit b2d20f5

Please sign in to comment.