Skip to content

Commit

Permalink
feat(ui): make brower configurable. Fixes #248
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 30, 2022
1 parent 730bb84 commit 679d85c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ return {
"",
},
},
-- leave nil, to automatically select a browser depending on your OS.
-- If you want to use a specific browser, you can define it here
browser = nil, ---@type string?
throttle = 20, -- how frequently should the ui process render events
custom_keys = {
-- you can define custom key maps here.
Expand Down
3 changes: 3 additions & 0 deletions lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ M.defaults = {
"",
},
},
-- leave nil, to automatically select a browser depending on your OS.
-- If you want to use a specific browser, you can define it here
browser = nil, ---@type string?
throttle = 20, -- how frequently should the ui process render events
custom_keys = {
-- you can define custom key maps here.
Expand Down
12 changes: 9 additions & 3 deletions lua/lazy/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ function M.open(uri)
if M.file_exists(uri) then
return M.float({ win_opts = { style = "" }, file = uri })
end
local Config = require("lazy.core.config")
local cmd
if vim.fn.has("win32") == 1 then
if Config.options.ui.browser then
cmd = { Config.options.ui.browser, uri }
elseif vim.fn.has("win32") == 1 then
cmd = { "explorer", uri }
-- cmd = { 'cmd.exe', '/c', 'start', '""', uri }
elseif vim.fn.has("macunix") == 1 then
cmd = { "open", uri }
else
cmd = { "xdg-open", uri }
if vim.fn.executable("xdg-open") then
cmd = { "xdg-open", uri }
else
cmd = { "open", uri }
end
end

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

0 comments on commit 679d85c

Please sign in to comment.