-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get the lsp response in vscode-language-client? #628
Comments
@Abbyyan the LSP client has a middleware which all requests and response go through. |
How can i get the full completion items in the server response? Should i use |
Is there some documents shows how to use them please? |
You probably want the former but you may want both depending on your exact use case.
Maybe the code from #322 may serve as a bit of a reference for you. |
Learned from lsp-example that i can change the input send to server (just as the uri in the example). But i still confused about get the response (or other info ) from server. For example , how can i get the completion list in provideCompletionItem? Hope for your answer please. Thanks for your help! let clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'html1' }],
middleware: {
provideCompletionItem: async (document, position, context, token, next) => {
// If not in `<style>`, do not perform request forwarding
if (!isInsideStyleRegion(htmlLanguageService, document.getText(), document.offsetAt(position))) {
return await next(document, position, context, token);
}
const originalUri = document.uri.toString();
virtualDocumentContents.set(originalUri, getCSSVirtualContent(htmlLanguageService, document.getText()));
const vdocUriString = `embedded-content://css/${encodeURIComponent(
originalUri
)}.css`;
const vdocUri = Uri.parse(vdocUriString);
return await commands.executeCommand<CompletionList>(
'vscode.executeCompletionItemProvider',
vdocUri,
position,
context.triggerCharacter
);
}
}
}; |
The result of |
Thanks for your help. It really works! Thanks a lot. By using provideCompletionItem: async (document: TextDocument,
position: Position, context: CompletionContext,
token: CancellationToken, next: ProvideCompletionItemsSignature) => {
if (true) {
const temp_result: any = await next(document, position, context, token);
if (temp_result) {
const temp_result_info: CompletionList = temp_result;
logChan("temp_result is not null " + temp_result_info.toLocaleString);
const items: any = temp_result_info.items;
items.forEach((element: CompletionItem) => {
logChan("completion element label = " + element.label + " detail = " + element.detail);
});
}
return temp_result;
}
return [];
}
}, |
provideCompletionItem: async (document: TextDocument,
position: Position, context: CompletionContext,
token: CancellationToken, next: ProvideCompletionItemsSignature) => {
const temp_result: any = await next(document, position, context, token);
const processed_result = some_process_func(temp_result)
return processed_result;
} I've tried it but it seems something doesn't work like this. Hope for your advice . Thanks a lot. |
@Abbyyan I don't understand. You just said it worked an hour ago (#628 (comment))? |
Yes, I can get the completion list can print it out. I intercept the response and process it . It confused me now that how can i send my processed response to vscode client? Thanks a lot. |
Aren't you doing that already with your |
I'm working on a vscode lsp extension development and want to ask if there are some methods that i can get the lsp response in the vscode-language-client ? Hope for your help. Thanks a lot.
The text was updated successfully, but these errors were encountered: