Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(esupports.hop): add open mode for external link target #1072

Merged
merged 1 commit into from
Sep 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lua/neorg/modules/core/esupports/hop/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ module.config.public = {
module.public = {
--- Follow link from a specific node
---@param node userdata
---@param split string|nil if not nil, will open a new split with the split mode defined (vsplitr...) or new tab (mode="tab")
---@param open_mode string|nil if not nil, will open a new split with the split mode defined (vsplitr...) or new tab (mode="tab") or with external app (mode="external")
---@param parsed_link table a table of link information gathered from parse_link()
follow_link = function(node, split, parsed_link)
follow_link = function(node, open_mode, parsed_link)
if node:type() == "anchor_declaration" then
local located_anchor_declaration = module.public.locate_anchor_declaration_target(node)

Expand Down Expand Up @@ -99,12 +99,12 @@ module.public = {
end

local function open_split()
if split then
if split == "vsplit" then
if open_mode then
if open_mode == "vsplit" then
vim.cmd("vsplit")
elseif split == "split" then
elseif open_mode == "split" then
vim.cmd("split")
elseif split == "tab" then
elseif open_mode == "tab" then
vim.cmd("tabnew")
end
end
Expand All @@ -120,6 +120,11 @@ module.public = {
end

if located_link_information then
if open_mode == "external" then
os_open_link(located_link_information.uri or located_link_information.path)
return
end

lib.match(located_link_information.type)({
-- If we're dealing with a URI, simply open the URI in the user's preferred method
external_app = function()
Expand Down