aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarshmallow <marshycity@gmail.com>2023-07-19 10:06:20 +1000
committerJustin M. Keyes <justinkz@gmail.com>2023-07-21 13:36:57 +0200
commit519b9929e94c94965b73ac4b04aedb03fd2708ca (patch)
tree39a2ad22f5fab1c840d01b4fe321ff0e32f8fa00
parentca9f4a7cb1fea1ef1f22c011679fd8afa0a5d161 (diff)
downloadrneovim-519b9929e94c94965b73ac4b04aedb03fd2708ca.tar.gz
rneovim-519b9929e94c94965b73ac4b04aedb03fd2708ca.tar.bz2
rneovim-519b9929e94c94965b73ac4b04aedb03fd2708ca.zip
fix(ui.open): some URLs fail on Windows
Problem: On Windows, `explorer.exe` fails to open some URLs, for example: :lua vim.ui.open('https://devdocs.io/#q=lua%20lua_call') https://github.com/neovim/neovim/pull/23401#issuecomment-1641015704 Solution: Use rundll32 instead.
-rw-r--r--runtime/lua/vim/ui.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua
index fd06611da2..87b52787a0 100644
--- a/runtime/lua/vim/ui.lua
+++ b/runtime/lua/vim/ui.lua
@@ -136,7 +136,11 @@ function M.open(path)
if vim.fn.has('mac') == 1 then
cmd = { 'open', path }
elseif vim.fn.has('win32') == 1 then
- cmd = { 'explorer', path }
+ if vim.fn.executable('rundll32') == 1 then
+ cmd = { 'rundll32', 'url.dll,FileProtocolHandler', path }
+ else
+ return nil, 'vim.ui.open: rundll32 not found'
+ end
elseif vim.fn.executable('wslview') == 1 then
cmd = { 'wslview', path }
elseif vim.fn.executable('xdg-open') == 1 then