feat(vim.ui): vim.ui.open, "gx" without netrw

Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Co-authored-by: ii14 <59243201+ii14@users.noreply.github.com>
This commit is contained in:
marshmallow
2023-04-30 15:53:02 +10:00
committed by Justin M. Keyes
parent 3ecd45ded0
commit af6e6ccf3d
6 changed files with 115 additions and 11 deletions

View File

@@ -573,22 +573,15 @@ M['window/showDocument'] = function(_, result, ctx, _)
if result.external then
-- TODO(lvimuser): ask the user for confirmation
local cmd
if vim.fn.has('win32') == 1 then
cmd = { 'cmd.exe', '/c', 'start', '""', uri }
elseif vim.fn.has('macunix') == 1 then
cmd = { 'open', uri }
else
cmd = { 'xdg-open', uri }
end
local ret = vim.fn.system(cmd)
if vim.v.shell_error ~= 0 then
local ret = vim.ui.open(uri)
if ret.code ~= 0 or ret == nil then
return {
success = false,
error = {
code = protocol.ErrorCodes.UnknownErrorCode,
message = ret,
message = ret and ret.stderr or 'No handler could be found',
},
}
end