@@ -17,6 +17,10 @@ mapping them):
1717
1818- `neorg.esupports.hop.hop-link` - Follow the link under the cursor, seeks forward
1919- `neorg.esupports.hop.hop-link.vsplit` - Same, but open the link in a vertical split
20+ - `neorg.esupports.hop.hop-link.tab-drop` - Same as hop-link, but open the link in a new tab; if the destination is already
21+ open in an existing tab then just navigate to that tab (check :help :drop)
22+ - `neorg.esupports.hop.hop-link.drop` - Same as hop-link, but navigate to the buffer if the destination is already open
23+ in an existing buffer (check :help :drop)
2024--]]
2125
2226local neorg = require (" neorg.core" )
@@ -42,6 +46,8 @@ module.load = function()
4246 dirman_utils = module .required [" core.dirman.utils" ]
4347 vim .keymap .set (" " , " <Plug>(neorg.esupports.hop.hop-link)" , module .public .hop_link )
4448 vim .keymap .set (" " , " <Plug>(neorg.esupports.hop.hop-link.vsplit)" , lib .wrap (module .public .hop_link , " vsplit" ))
49+ vim .keymap .set (" " , " <Plug>(neorg.esupports.hop.hop-link.drop)" , lib .wrap (module .public .hop_link , " drop" ))
50+ vim .keymap .set (" " , " <Plug>(neorg.esupports.hop.hop-link.tab-drop)" , lib .wrap (module .public .hop_link , " tab-drop" ))
4551end
4652
4753module .config .public = {
@@ -216,11 +222,19 @@ module.public = {
216222 end ,
217223
218224 buffer = function ()
219- open_split ()
225+ if open_mode ~= " tab-drop" and open_mode ~= " drop" then
226+ open_split ()
227+ end
220228
221229 if located_link_information .buffer ~= vim .api .nvim_get_current_buf () then
222- vim .api .nvim_buf_set_option (located_link_information .buffer , " buflisted" , true )
223- vim .api .nvim_set_current_buf (located_link_information .buffer )
230+ if open_mode == " tab-drop" then
231+ vim .cmd (" tab drop " .. vim .api .nvim_buf_get_name (located_link_information .buffer ))
232+ elseif open_mode == " drop" then
233+ vim .cmd (" drop " .. vim .api .nvim_buf_get_name (located_link_information .buffer ))
234+ else
235+ vim .api .nvim_buf_set_option (located_link_information .buffer , " buflisted" , true )
236+ vim .api .nvim_set_current_buf (located_link_information .buffer )
237+ end
224238 end
225239
226240 if located_link_information .line then
0 commit comments