From e9e17f7d78a2fdfd379f16ff68317208e1d60c27 Mon Sep 17 00:00:00 2001 From: Devansh Sharma Date: Fri, 1 Nov 2024 10:17:44 +0530 Subject: [PATCH 1/6] feat(esupports.hop): Add tab drop as option for open_mode --- lua/neorg/modules/core/esupports/hop/module.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/neorg/modules/core/esupports/hop/module.lua b/lua/neorg/modules/core/esupports/hop/module.lua index eddfedff8..d4609330f 100644 --- a/lua/neorg/modules/core/esupports/hop/module.lua +++ b/lua/neorg/modules/core/esupports/hop/module.lua @@ -42,6 +42,7 @@ module.load = function() dirman_utils = module.required["core.dirman.utils"] 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")) + vim.keymap.set("", "(neorg.esupports.hop.hop-link.tab-drop)", lib.wrap(module.public.hop_link, "tab-drop")) end module.config.public = { @@ -216,9 +217,16 @@ module.public = { end, buffer = function() - open_split() + if open_mode ~= "tab-drop" then + open_split() + end if located_link_information.buffer ~= vim.api.nvim_get_current_buf() then + if open_mode == "tab-drop" then + vim.cmd("tab drop " .. vim.api.nvim_buf_get_name(located_link_information.buffer)) + return + end + vim.api.nvim_buf_set_option(located_link_information.buffer, "buflisted", true) vim.api.nvim_set_current_buf(located_link_information.buffer) end From 2c1082ba3bc107e5d4526bc40ee53fe6444509fe Mon Sep 17 00:00:00 2001 From: Devansh Sharma Date: Fri, 1 Nov 2024 10:35:03 +0530 Subject: [PATCH 2/6] docs(esupports.hop): Document keybinds for tab-drop --- lua/neorg/modules/core/esupports/hop/module.lua | 2 ++ lua/neorg/modules/core/keybinds/module.lua | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/lua/neorg/modules/core/esupports/hop/module.lua b/lua/neorg/modules/core/esupports/hop/module.lua index d4609330f..f72e72bad 100644 --- a/lua/neorg/modules/core/esupports/hop/module.lua +++ b/lua/neorg/modules/core/esupports/hop/module.lua @@ -17,6 +17,8 @@ mapping them): - `neorg.esupports.hop.hop-link` - Follow the link under the cursor, seeks forward - `neorg.esupports.hop.hop-link.vsplit` - Same, but open the link in a vertical split +- `neorg.esupports.hop.hop-link.tab-drop` - Same as hop-link, but open the link in a new tab; if the destination is already + open in an existing tab then just navigate to that tab (check :help :drop) --]] local neorg = require("neorg.core") diff --git a/lua/neorg/modules/core/keybinds/module.lua b/lua/neorg/modules/core/keybinds/module.lua index d66d8ffb8..ddcde9d64 100644 --- a/lua/neorg/modules/core/keybinds/module.lua +++ b/lua/neorg/modules/core/keybinds/module.lua @@ -298,6 +298,14 @@ module.private = { opts = { desc = "[neorg] Jump to Link (Vertical Split)" }, }, + -- Same as ``, except open the destination in a new tab + -- If destination is already open in an existing tab, just navigate to it + { + "", + "(neorg.esupports.hop.hop-link.tab-drop)", + opts = { desc = "[neorg] Jump to Link (Tab Drop)" }, + }, + -- Promote an object non-recursively { ">.", From d21c80cab59bd56d51e9102c2b39ba571ad1f71f Mon Sep 17 00:00:00 2001 From: Devansh Sharma Date: Fri, 1 Nov 2024 12:57:17 +0530 Subject: [PATCH 3/6] feat(esupports.hop): Add drop as option for open_mode --- lua/neorg/modules/core/esupports/hop/module.lua | 8 +++++++- lua/neorg/modules/core/keybinds/module.lua | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/neorg/modules/core/esupports/hop/module.lua b/lua/neorg/modules/core/esupports/hop/module.lua index f72e72bad..8300f41eb 100644 --- a/lua/neorg/modules/core/esupports/hop/module.lua +++ b/lua/neorg/modules/core/esupports/hop/module.lua @@ -19,6 +19,8 @@ mapping them): - `neorg.esupports.hop.hop-link.vsplit` - Same, but open the link in a vertical split - `neorg.esupports.hop.hop-link.tab-drop` - Same as hop-link, but open the link in a new tab; if the destination is already open in an existing tab then just navigate to that tab (check :help :drop) +- `neorg.esupports.hop.hop-link.drop` - Same as hop-link, but navigate to the buffer if the destination is already open + in an existing buffer (check :help :drop) --]] local neorg = require("neorg.core") @@ -44,6 +46,7 @@ module.load = function() dirman_utils = module.required["core.dirman.utils"] 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")) + vim.keymap.set("", "(neorg.esupports.hop.hop-link.drop)", lib.wrap(module.public.hop_link, "drop")) vim.keymap.set("", "(neorg.esupports.hop.hop-link.tab-drop)", lib.wrap(module.public.hop_link, "tab-drop")) end @@ -219,7 +222,7 @@ module.public = { end, buffer = function() - if open_mode ~= "tab-drop" then + if open_mode ~= "tab-drop" and open_mode ~= "drop" then open_split() end @@ -227,6 +230,9 @@ module.public = { if open_mode == "tab-drop" then vim.cmd("tab drop " .. vim.api.nvim_buf_get_name(located_link_information.buffer)) return + elseif open_mode == "drop" then + vim.cmd("drop " .. vim.api.nvim_buf_get_name(located_link_information.buffer)) + return end vim.api.nvim_buf_set_option(located_link_information.buffer, "buflisted", true) diff --git a/lua/neorg/modules/core/keybinds/module.lua b/lua/neorg/modules/core/keybinds/module.lua index ddcde9d64..919cc615b 100644 --- a/lua/neorg/modules/core/keybinds/module.lua +++ b/lua/neorg/modules/core/keybinds/module.lua @@ -306,6 +306,13 @@ module.private = { opts = { desc = "[neorg] Jump to Link (Tab Drop)" }, }, + -- Same as ``, except if destination is already open in a buffer, just navigate to it + { + "", + "(neorg.esupports.hop.hop-link.drop)", + opts = { desc = "[neorg] Jump to Link (Drop)" }, + }, + -- Promote an object non-recursively { ">.", From fe8d0838fd351aaf62917c4ee301c86f14cc924e Mon Sep 17 00:00:00 2001 From: Devansh Sharma Date: Sat, 2 Nov 2024 20:17:22 +0530 Subject: [PATCH 4/6] fix(esupports.hop): Fix condition to allow jump to line for drop modes --- lua/neorg/modules/core/esupports/hop/module.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lua/neorg/modules/core/esupports/hop/module.lua b/lua/neorg/modules/core/esupports/hop/module.lua index 8300f41eb..fadcb20b3 100644 --- a/lua/neorg/modules/core/esupports/hop/module.lua +++ b/lua/neorg/modules/core/esupports/hop/module.lua @@ -229,14 +229,12 @@ module.public = { if located_link_information.buffer ~= vim.api.nvim_get_current_buf() then if open_mode == "tab-drop" then vim.cmd("tab drop " .. vim.api.nvim_buf_get_name(located_link_information.buffer)) - return elseif open_mode == "drop" then vim.cmd("drop " .. vim.api.nvim_buf_get_name(located_link_information.buffer)) - return + else + vim.api.nvim_buf_set_option(located_link_information.buffer, "buflisted", true) + vim.api.nvim_set_current_buf(located_link_information.buffer) end - - vim.api.nvim_buf_set_option(located_link_information.buffer, "buflisted", true) - vim.api.nvim_set_current_buf(located_link_information.buffer) end if located_link_information.line then From 7dccc98a7893915baef46a951ce4789438646ba0 Mon Sep 17 00:00:00 2001 From: Devansh Sharma Date: Sun, 10 Nov 2024 01:23:30 +0530 Subject: [PATCH 5/6] fix(esupports.hop): Remove default mapping for C-d --- lua/neorg/modules/core/keybinds/module.lua | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lua/neorg/modules/core/keybinds/module.lua b/lua/neorg/modules/core/keybinds/module.lua index 919cc615b..ddcde9d64 100644 --- a/lua/neorg/modules/core/keybinds/module.lua +++ b/lua/neorg/modules/core/keybinds/module.lua @@ -306,13 +306,6 @@ module.private = { opts = { desc = "[neorg] Jump to Link (Tab Drop)" }, }, - -- Same as ``, except if destination is already open in a buffer, just navigate to it - { - "", - "(neorg.esupports.hop.hop-link.drop)", - opts = { desc = "[neorg] Jump to Link (Drop)" }, - }, - -- Promote an object non-recursively { ">.", From 6278455793d67984a84af35aff9c86d02b071f79 Mon Sep 17 00:00:00 2001 From: Devansh Sharma Date: Thu, 14 Nov 2024 08:58:58 +0530 Subject: [PATCH 6/6] fix(esupports.hop): Use different mapping for tab drop --- lua/neorg/modules/core/keybinds/module.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/neorg/modules/core/keybinds/module.lua b/lua/neorg/modules/core/keybinds/module.lua index ddcde9d64..63ec941d3 100644 --- a/lua/neorg/modules/core/keybinds/module.lua +++ b/lua/neorg/modules/core/keybinds/module.lua @@ -301,7 +301,7 @@ module.private = { -- Same as ``, except open the destination in a new tab -- If destination is already open in an existing tab, just navigate to it { - "", + "", "(neorg.esupports.hop.hop-link.tab-drop)", opts = { desc = "[neorg] Jump to Link (Tab Drop)" }, },