Skip to content

Commit cdfbe19

Browse files
committed
refactor!: move esupports.hop to the new keybind schema
1 parent ecf5f41 commit cdfbe19

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

Diff for: lua/neorg/modules/core/esupports/hop/module.lua

+15-20
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ end
3232
module.load = function()
3333
links = module.required["core.links"]
3434
dirman_utils = module.required["core.dirman.utils"]
35-
modules.await("core.keybinds", function(keybinds)
36-
keybinds.register_keybind(module.name, "hop-link")
37-
end)
35+
vim.keymap.set("", "<Plug>(neorg.esupports.hop.hop-link)", module.public.hop_link)
36+
vim.keymap.set("", "<Plug>(neorg.esupports.hop.hop-link.vsplit)", lib.wrap(module.public.hop_link, "vsplit"))
3837
end
3938

4039
module.config.public = {
@@ -677,6 +676,19 @@ module.public = {
677676
end,
678677
} --[[@as table<string, fun(): LinkTarget?>]])
679678
end,
679+
680+
hop_link = function(split_mode)
681+
local link_node_at_cursor = module.public.extract_link_node()
682+
683+
if not link_node_at_cursor then
684+
log.trace("No link under cursor.")
685+
return
686+
end
687+
688+
local parsed_link = module.public.parse_link(link_node_at_cursor)
689+
690+
module.public.follow_link(link_node_at_cursor, split_mode, parsed_link)
691+
end
680692
}
681693

682694
module.private = {
@@ -946,23 +958,6 @@ module.private = {
946958
end,
947959
}
948960

949-
module.on_event = function(event)
950-
if event.split_type[2] == "core.esupports.hop.hop-link" then
951-
local split_mode = event.content[1]
952-
953-
local link_node_at_cursor = module.public.extract_link_node()
954-
955-
if not link_node_at_cursor then
956-
log.trace("No link under cursor.")
957-
return
958-
end
959-
960-
local parsed_link = module.public.parse_link(link_node_at_cursor)
961-
962-
module.public.follow_link(link_node_at_cursor, split_mode, parsed_link)
963-
end
964-
end
965-
966961
module.events.subscribed = {
967962
["core.keybinds"] = {
968963
["core.esupports.hop.hop-link"] = true,

Diff for: lua/neorg/modules/core/keybinds/module.lua

+4-3
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ module.private = {
119119

120120
-- Hop to the destination of the link under the cursor
121121
{ "<CR>", "<Plug>(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } },
122-
{ "gd", "<Plug>(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } },
123-
{ "gf", "<Plug>(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } },
124-
{ "gF", "<Plug>(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } },
122+
-- TODO: Move these to the "vim" preset
123+
-- { "gd", "<Plug>(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } },
124+
-- { "gf", "<Plug>(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } },
125+
-- { "gF", "<Plug>(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } },
125126

126127
-- Same as `<CR>`, except opens the destination in a vertical split
127128
{

Diff for: lua/neorg/modules/core/qol/todo_items/module.lua

-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ module.private = {
421421
end
422422

423423
module.public = {
424-
425424
task_done = task_set("x", "done"),
426425
task_undone = task_set(" ", "undone"),
427426
task_pending = task_set("-", "pending"),

0 commit comments

Comments
 (0)