autoload/lsp/handlers.vim | 31 +++++++++++++++++++++++++++++-- diff --git a/autoload/lsp/handlers.vim b/autoload/lsp/handlers.vim index 1af665141d25e230b9813367777a59ecf9e188b8..d86156f1953207194d14055c38a4cda8682d0ee9 100644 --- a/autoload/lsp/handlers.vim +++ b/autoload/lsp/handlers.vim @@ -84,7 +84,7 @@ # process the 'initialize' method reply from the LSP server # Result: InitializeResult def ProcessInitializeReply(lspserver: dict, req: dict, reply: dict): void - if reply.result->len() <= 0 + if reply.result->empty() return endif @@ -149,6 +149,9 @@ # process the 'textDocument/signatureHelp' reply from the LSP server # Result: SignatureHelp | null def ProcessSignaturehelpReply(lspserver: dict, req: dict, reply: dict): void + if reply.result->empty() + return + endif signature.SignatureDisplay(lspserver, reply.result) enddef @@ -343,6 +346,12 @@ # process the 'textDocument/references' reply from the LSP server # Result: Location[] | null def ProcessReferencesReply(lspserver: dict, req: dict, reply: dict): void + if reply.result->empty() + util.WarnMsg('Error: No references found') + lspserver.peekSymbol = false + return + endif + symbol.ShowReferences(lspserver, reply.result) enddef @@ -524,12 +533,22 @@ # process the 'textDocument/codeAction' reply from the LSP server # Result: (Command | CodeAction)[] | null def ProcessCodeActionReply(lspserver: dict, req: dict, reply: dict) + if reply.result->empty() + # no action can be performed + util.WarnMsg('No code action is available') + return + endif + codeaction.ApplyCodeAction(lspserver, reply.result) enddef # Reply: 'textDocument/selectionRange' # Result: SelectionRange[] | null def ProcessSelectionRangeReply(lspserver: dict, req: dict, reply: dict) + if reply.result->empty() + return + endif + selection.SelectionStart(lspserver, reply.result) enddef @@ -599,7 +618,7 @@ var fileName: string var r: dict> var symName: string - if reply.result->type() != v:t_list + if reply.result->empty() return endif @@ -665,12 +684,20 @@ # process the 'callHierarchy/incomingCalls' reply from the LSP server # Result: CallHierarchyIncomingCall[] | null def ProcessIncomingCalls(lspserver: dict, req: dict, reply: dict) + if reply.result->empty() + return + endif + callhier.IncomingCalls(reply.result) enddef # process the 'callHierarchy/outgoingCalls' reply from the LSP server # Result: CallHierarchyOutgoingCall[] | null def ProcessOutgoingCalls(lspserver: dict, req: dict, reply: dict) + if reply.result->empty() + return + endif + callhier.OutgoingCalls(reply.result) enddef