@@ -17,6 +17,10 @@ mapping them):
17
17
18
18
- `neorg.esupports.hop.hop-link` - Follow the link under the cursor, seeks forward
19
19
- `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)
20
24
--]]
21
25
22
26
local neorg = require (" neorg.core" )
@@ -42,6 +46,8 @@ module.load = function()
42
46
dirman_utils = module .required [" core.dirman.utils" ]
43
47
vim .keymap .set (" " , " <Plug>(neorg.esupports.hop.hop-link)" , module .public .hop_link )
44
48
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" ))
45
51
end
46
52
47
53
module .config .public = {
@@ -216,11 +222,19 @@ module.public = {
216
222
end ,
217
223
218
224
buffer = function ()
219
- open_split ()
225
+ if open_mode ~= " tab-drop" and open_mode ~= " drop" then
226
+ open_split ()
227
+ end
220
228
221
229
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
224
238
end
225
239
226
240
if located_link_information .line then
0 commit comments