local M = {} local header_regex = "^(#+) (.+)" M.headerControl = function(action) local current_line = vim.api.nvim_get_current_line() local row = vim.api.nvim_win_get_cursor(0)[1] if current_line:match(header_regex) then if action == "promote" then if current_line:match("^# (.+)") then vim.notify("You can't promote this header anymore") return end vim.api.nvim_buf_set_text(0, row - 1, 0, row - 1, 1, { "" }) elseif action == "demote" then if current_line:match("^###### (.+)") then vim.notify("You can't demote this header anymore") return end vim.api.nvim_buf_set_text(0, row - 1, 0, row - 1, 0, { "#" }) end end end return M