Skip to content

Commit 1093523

Browse files
authored
Merge pull request #102 from chrishrb/77-option-to-disable-prompt-when-multiple-handlers-match
77 Add option to disable prompt when multiple handlers match
2 parents d730e1f + 85f5e74 commit 1093523

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ require("lazy").setup({
5252
vim.fn.setreg("+", url) -- for example, you can set the url to clipboard here
5353
end,
5454

55+
select_prompt = true, -- shows a prompt when multiple handlers match; disable to auto-select the top one
56+
5557
handlers = {
5658
plugin = true, -- open plugin links in lua (e.g. packer, lazy, ..)
5759
github = true, -- open github issues

lua/gx/init.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ local M = {}
2121
---@field open_browser_app string
2222
---@field open_browser_args string[]
2323
---@field open_callback boolean|function
24+
---@field select_prompt boolean
2425
---@field handlers table<string, boolean|GxHandler>
2526
---@field handler_options GxHandlerOptions
2627

@@ -43,7 +44,7 @@ function M.open(mode, line)
4344

4445
if #urls == 0 then
4546
return
46-
elseif #urls == 1 then
47+
elseif #urls == 1 or M.options.select_prompt == false then
4748
if M.options.open_callback then
4849
M.options.open_callback(urls[1].url)
4950
end
@@ -103,6 +104,7 @@ local function with_defaults(options)
103104
options.open_browser_args = options.open_browser_args or get_open_browser_args()
104105
options.open_callback = options.open_callback or false
105106
options.handlers = options.handlers or {}
107+
options.select_prompt = options.select_prompt == nil and true or options.select_prompt
106108
options.handler_options = options.handler_options or {}
107109
options.handler_options.search_engine = options.handler_options.search_engine or "google"
108110
options.handler_options.select_for_search = options.handler_options.select_for_search or false

0 commit comments

Comments
 (0)