Skip to content

Commit 679d85c

Browse files
committed
feat(ui): make brower configurable. Fixes #248
1 parent 730bb84 commit 679d85c

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ return {
345345
"",
346346
},
347347
},
348+
-- leave nil, to automatically select a browser depending on your OS.
349+
-- If you want to use a specific browser, you can define it here
350+
browser = nil, ---@type string?
348351
throttle = 20, -- how frequently should the ui process render events
349352
custom_keys = {
350353
-- you can define custom key maps here.

lua/lazy/core/config.lua

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ M.defaults = {
5959
"",
6060
},
6161
},
62+
-- leave nil, to automatically select a browser depending on your OS.
63+
-- If you want to use a specific browser, you can define it here
64+
browser = nil, ---@type string?
6265
throttle = 20, -- how frequently should the ui process render events
6366
custom_keys = {
6467
-- you can define custom key maps here.

lua/lazy/util.lua

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ function M.open(uri)
1818
if M.file_exists(uri) then
1919
return M.float({ win_opts = { style = "" }, file = uri })
2020
end
21+
local Config = require("lazy.core.config")
2122
local cmd
22-
if vim.fn.has("win32") == 1 then
23+
if Config.options.ui.browser then
24+
cmd = { Config.options.ui.browser, uri }
25+
elseif vim.fn.has("win32") == 1 then
2326
cmd = { "explorer", uri }
24-
-- cmd = { 'cmd.exe', '/c', 'start', '""', uri }
2527
elseif vim.fn.has("macunix") == 1 then
2628
cmd = { "open", uri }
2729
else
28-
cmd = { "xdg-open", uri }
30+
if vim.fn.executable("xdg-open") then
31+
cmd = { "xdg-open", uri }
32+
else
33+
cmd = { "open", uri }
34+
end
2935
end
3036

3137
local ret = vim.fn.jobstart(cmd, { detach = true })

0 commit comments

Comments
 (0)