mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix(vim.ui.open): use explorer.exe instead of wslview #26947
Problem: `vim.ui.open` uses `wslview`, which is slow and require a package from external PPA: https://wslutiliti.es/wslu/install.html#ubuntu Solution: Use `explorer.exe` instead. WSL supports it by default: https://learn.microsoft.com/en-us/windows/wsl/filesystems#view-your-current-directory-in-windows-file-explorer
This commit is contained in:
@@ -143,12 +143,12 @@ function M.open(path)
|
|||||||
else
|
else
|
||||||
return nil, 'vim.ui.open: rundll32 not found'
|
return nil, 'vim.ui.open: rundll32 not found'
|
||||||
end
|
end
|
||||||
elseif vim.fn.executable('wslview') == 1 then
|
elseif vim.fn.executable('explorer.exe') == 1 then
|
||||||
cmd = { 'wslview', path }
|
cmd = { 'explorer.exe', path }
|
||||||
elseif vim.fn.executable('xdg-open') == 1 then
|
elseif vim.fn.executable('xdg-open') == 1 then
|
||||||
cmd = { 'xdg-open', path }
|
cmd = { 'xdg-open', path }
|
||||||
else
|
else
|
||||||
return nil, 'vim.ui.open: no handler found (tried: wslview, xdg-open)'
|
return nil, 'vim.ui.open: no handler found (tried: explorer.exe, xdg-open)'
|
||||||
end
|
end
|
||||||
|
|
||||||
local rv = vim.system(cmd, { text = true, detach = true }):wait()
|
local rv = vim.system(cmd, { text = true, detach = true }):wait()
|
||||||
|
@@ -152,7 +152,7 @@ describe('vim.ui', function()
|
|||||||
vim.fn.executable = function() return 0 end
|
vim.fn.executable = function() return 0 end
|
||||||
]]
|
]]
|
||||||
eq(
|
eq(
|
||||||
'vim.ui.open: no handler found (tried: wslview, xdg-open)',
|
'vim.ui.open: no handler found (tried: explorer.exe, xdg-open)',
|
||||||
exec_lua [[local _, err = vim.ui.open('foo') ; return err]]
|
exec_lua [[local _, err = vim.ui.open('foo') ; return err]]
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user