From cdfbe19125a5d71288ea5c28f7916f709ca57ddd Mon Sep 17 00:00:00 2001 From: vhyrro Date: Tue, 9 Jul 2024 10:29:09 +0200 Subject: [PATCH] refactor!: move esupports.hop to the new keybind schema --- .../modules/core/esupports/hop/module.lua | 35 ++++++++----------- lua/neorg/modules/core/keybinds/module.lua | 7 ++-- .../modules/core/qol/todo_items/module.lua | 1 - 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/lua/neorg/modules/core/esupports/hop/module.lua b/lua/neorg/modules/core/esupports/hop/module.lua index 7fb75ebf2..1ad36e15a 100644 --- a/lua/neorg/modules/core/esupports/hop/module.lua +++ b/lua/neorg/modules/core/esupports/hop/module.lua @@ -32,9 +32,8 @@ end module.load = function() links = module.required["core.links"] dirman_utils = module.required["core.dirman.utils"] - modules.await("core.keybinds", function(keybinds) - keybinds.register_keybind(module.name, "hop-link") - end) + vim.keymap.set("", "(neorg.esupports.hop.hop-link)", module.public.hop_link) + vim.keymap.set("", "(neorg.esupports.hop.hop-link.vsplit)", lib.wrap(module.public.hop_link, "vsplit")) end module.config.public = { @@ -677,6 +676,19 @@ module.public = { end, } --[[@as table]]) end, + + hop_link = function(split_mode) + local link_node_at_cursor = module.public.extract_link_node() + + if not link_node_at_cursor then + log.trace("No link under cursor.") + return + end + + local parsed_link = module.public.parse_link(link_node_at_cursor) + + module.public.follow_link(link_node_at_cursor, split_mode, parsed_link) + end } module.private = { @@ -946,23 +958,6 @@ module.private = { end, } -module.on_event = function(event) - if event.split_type[2] == "core.esupports.hop.hop-link" then - local split_mode = event.content[1] - - local link_node_at_cursor = module.public.extract_link_node() - - if not link_node_at_cursor then - log.trace("No link under cursor.") - return - end - - local parsed_link = module.public.parse_link(link_node_at_cursor) - - module.public.follow_link(link_node_at_cursor, split_mode, parsed_link) - end -end - module.events.subscribed = { ["core.keybinds"] = { ["core.esupports.hop.hop-link"] = true, diff --git a/lua/neorg/modules/core/keybinds/module.lua b/lua/neorg/modules/core/keybinds/module.lua index 38bbadc5d..be60b9bfd 100644 --- a/lua/neorg/modules/core/keybinds/module.lua +++ b/lua/neorg/modules/core/keybinds/module.lua @@ -119,9 +119,10 @@ module.private = { -- Hop to the destination of the link under the cursor { "", "(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } }, - { "gd", "(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } }, - { "gf", "(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } }, - { "gF", "(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } }, + -- TODO: Move these to the "vim" preset + -- { "gd", "(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } }, + -- { "gf", "(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } }, + -- { "gF", "(neorg.esupports.hop.hop-link)", opts = { desc = "[neorg] Jump to Link" } }, -- Same as ``, except opens the destination in a vertical split { diff --git a/lua/neorg/modules/core/qol/todo_items/module.lua b/lua/neorg/modules/core/qol/todo_items/module.lua index 32fb1d8f0..471a36a89 100644 --- a/lua/neorg/modules/core/qol/todo_items/module.lua +++ b/lua/neorg/modules/core/qol/todo_items/module.lua @@ -421,7 +421,6 @@ module.private = { end module.public = { - task_done = task_set("x", "done"), task_undone = task_set(" ", "undone"), task_pending = task_set("-", "pending"),