Skip to content

Commit 9197cf8

Browse files
committed
feat(Leet open): use vim.ui.open
1 parent 6a2e54f commit 9197cf8

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

lua/leetcode/command/init.lua

+15-11
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,23 @@ function cmd.open()
304304
local q = utils.curr_question()
305305

306306
if q then
307-
local command
308-
local os_name = vim.loop.os_uname().sysname
309-
310-
if os_name == "Linux" then
311-
command = string.format("xdg-open '%s'", q.cache.link)
312-
elseif os_name == "Darwin" then
313-
command = string.format("open '%s'", q.cache.link)
307+
if vim.ui.open then
308+
vim.ui.open(q.cache.link)
314309
else
315-
-- Fallback to Windows if uname is not available or does not match Linux/Darwin.
316-
command = string.format("start \"\" \"%s\"", q.cache.link)
317-
end
310+
local command
311+
local os_name = vim.loop.os_uname().sysname
312+
313+
if os_name == "Linux" then
314+
command = string.format("xdg-open '%s'", q.cache.link)
315+
elseif os_name == "Darwin" then
316+
command = string.format("open '%s'", q.cache.link)
317+
else
318+
-- Fallback to Windows if uname is not available or does not match Linux/Darwin.
319+
command = string.format("start \"\" \"%s\"", q.cache.link)
320+
end
318321

319-
vim.fn.jobstart(command, { detach = true })
322+
vim.fn.jobstart(command, { detach = true })
323+
end
320324
end
321325
end
322326

0 commit comments

Comments
 (0)