Skip to content

Commit

Permalink
fix(promo): promote/demote range + keybinds
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas committed Jun 26, 2024
1 parent 3285cfd commit 8f89476
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
9 changes: 4 additions & 5 deletions lua/neorg/modules/core/keybinds/keybinds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ module.config.public = {
{ "<M-d>", "core.tempus.insert-date-insert-mode", opts = { desc = "[neorg] Insert Date" } },
},

-- TODO: Readd these
-- v = {
-- { ">>", ":<cr><cmd>Neorg keybind all core.promo.promote_range<cr>" },
-- { "<<", ":<cr><cmd>Neorg keybind all core.promo.demote_range<cr>" },
-- },
v = {
{ ">", "core.promo.promote_range", opts = { desc = "[neorg] Promote Objects in Range" } },
{ "<", "core.promo.demote_range", opts = { desc = "[neorg] Demote Objects in Range" } },
},
}, {
silent = true,
noremap = true,
Expand Down
28 changes: 2 additions & 26 deletions lua/neorg/modules/core/promo/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -320,38 +320,14 @@ module.on_event = neorg.utils.wrap_dotrepeat(function(event)
local end_pos = vim.api.nvim_buf_get_mark(event.buffer, ">")

for i = 0, end_pos[1] - start_pos[1] do
module.public.promote_or_demote(event.buffer, "promote", start_pos[1] + i)
end

if modules.loaded_modules["core.concealer"] then
modules.broadcast_event(
assert(
modules.create_event(
modules.loaded_modules["core.concealer"],
"core.concealer.events.update_region",
{ start = start_pos[1] - 1, ["end"] = end_pos[1] + 2 }
)
)
)
module.public.promote_or_demote(event.buffer, "promote", start_pos[1] + i - 1, true, false)
end
elseif event.split_type[2] == "core.promo.demote_range" then
local start_pos = vim.api.nvim_buf_get_mark(event.buffer, "<")
local end_pos = vim.api.nvim_buf_get_mark(event.buffer, ">")

for i = 0, end_pos[1] - start_pos[1] do
module.public.promote_or_demote(event.buffer, "demote", start_pos[1] + i)
end

if modules.loaded_modules["core.concealer"] then
modules.broadcast_event(
assert(
modules.create_event(
modules.loaded_modules["core.concealer"],
"core.concealer.events.update_region",
{ start = start_pos[1] - 1, ["end"] = end_pos[1] + 2 }
)
)
)
module.public.promote_or_demote(event.buffer, "demote", start_pos[1] + i - 1, true, false)
end
end
end)
Expand Down

0 comments on commit 8f89476

Please sign in to comment.