Skip to content

Commit

Permalink
feat(Leet open): use vim.ui.open
Browse files Browse the repository at this point in the history
  • Loading branch information
kawre committed Nov 14, 2024
1 parent 6a2e54f commit 9197cf8
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lua/leetcode/command/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,23 @@ function cmd.open()
local q = utils.curr_question()

if q then
local command
local os_name = vim.loop.os_uname().sysname

if os_name == "Linux" then
command = string.format("xdg-open '%s'", q.cache.link)
elseif os_name == "Darwin" then
command = string.format("open '%s'", q.cache.link)
if vim.ui.open then
vim.ui.open(q.cache.link)
else
-- Fallback to Windows if uname is not available or does not match Linux/Darwin.
command = string.format("start \"\" \"%s\"", q.cache.link)
end
local command
local os_name = vim.loop.os_uname().sysname

if os_name == "Linux" then
command = string.format("xdg-open '%s'", q.cache.link)
elseif os_name == "Darwin" then
command = string.format("open '%s'", q.cache.link)
else
-- Fallback to Windows if uname is not available or does not match Linux/Darwin.
command = string.format("start \"\" \"%s\"", q.cache.link)
end

vim.fn.jobstart(command, { detach = true })
vim.fn.jobstart(command, { detach = true })
end
end
end

Expand Down

0 comments on commit 9197cf8

Please # to comment.