fix(vim.ui.open): return (don't show) error message

Problem:
Showing an error via vim.notify() makes it awkward for callers such as
lsp/handlers.lua to avoid showing redundant errors.

Solution:
Return the message instead of showing it. Let the caller decide whether
and when to show the message.
This commit is contained in:
Justin M. Keyes
2023-07-04 23:33:23 +02:00
parent 67b2ed1004
commit e644e7ce0b
5 changed files with 38 additions and 23 deletions

View File

@@ -573,15 +573,14 @@ M['window/showDocument'] = function(_, result, ctx, _)
if result.external then
-- TODO(lvimuser): ask the user for confirmation
local ret = vim.ui.open(uri)
local ret, err = vim.ui.open(uri)
if ret == nil or ret.code ~= 0 then
return {
success = false,
error = {
code = protocol.ErrorCodes.UnknownErrorCode,
message = ret and ret.stderr or 'No handler found',
message = ret and ret.stderr or err,
},
}
end