irongit

A Neovim plugin enabling you to solve LeetCode problems.

feat(`Leet open`): use `vim.ui.open`

kawreauthored
parent 6a2e54fcommit 9197cf8f09b8b50056388a6792e058af818468feBrowse files

1 file changed, +15 -11

+15-11lua/leetcode/command/init.lua
@@ -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