A Neovim plugin enabling you to solve LeetCode problems.
feat(`Leet open`): use `vim.ui.open`
1 file changed, +15 -11
+15-11lua/leetcode/command/init.lua
| @@ -304,19 +304,23 @@ function cmd.open() | ||
| 304 | 304 | local q = utils.curr_question() |
| 305 | 305 | |
| 306 | 306 | 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) | |
| 314 | 309 | 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 | |
| 318 | 321 | |
| 319 | - vim.fn.jobstart(command, { detach = true }) | |
| 322 | + vim.fn.jobstart(command, { detach = true }) | |
| 323 | + end | |
| 320 | 324 | end |
| 321 | 325 | end |
| 322 | 326 |