-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Add await
syntax support for sending edit request to client
#350
Conversation
Thanks for the PR. Is this just a quality of life thing? As in await/async is just more conventional? Or is there a deeper more practical reason? I wonder if this could be applied as default to all calls that use |
The code is cleaner, simpler, clearer (see issue description). On the practical side we can form a response for the client, depending on the result of editing the workspace. from pygls import server
LSP_SERVER = server.LanguageServer(...)
@LSP_SERVER.command('some_command')
async def some_command(ls: server.LanguageServer):
...
result = await ls.apply_edit_async(WorkspaceEdit(...))
if result.applied:
response = ResponseMessage(...)
else:
response = ResponseMessage(...)
return response
No, Line 390 in 464846b
Line 395 in 464846b
Line 452 in 464846b
Line 457 in 464846b
How to understand "applied by default"? Features and commands can be registered as synchronous and asynchronous functions. All methods that use |
Ohh, so you're just filling in a missing part of a convention we already have. That makes total sense. Ok, LGTM 🚢 Regarding the It looks like you just need to rebase |
bump @oliversen can I help? |
aa9251a
to
90b6bba
Compare
Done! |
The CI lint error wants a commit message more like And a rebase from main to get the latest changes. |
90b6bba
to
939f1a4
Compare
Sorry I didn't notice before, but the commit also needs formatting with |
|
I love your prompt 🥹 This is the diff I'm seeing diff --git a/pygls/protocol.py b/pygls/protocol.py
index 62b1f8a..28b7d90 100644
--- a/pygls/protocol.py
+++ b/pygls/protocol.py
@@ -746,8 +746,9 @@ class LanguageServerProtocol(JsonRPCProtocol, metaclass=LSPMeta):
self, edit: WorkspaceEdit, label: Optional[str] = None
) -> WorkspaceApplyEditResponse:
"""Sends apply edit request to the client. Should be called with `await`"""
- return self.send_request_async(WORKSPACE_APPLY_EDIT,
- ApplyWorkspaceEditParams(edit=edit, label=label))
+ return self.send_request_async(
+ WORKSPACE_APPLY_EDIT, ApplyWorkspaceEditParams(edit=edit, label=label)
+ )
@lsp_method(EXIT)
def lsp_exit(self, *args) -> None:
I see your prompt is saying it's on branch |
939f1a4
to
637d3fd
Compare
Description (e.g. "Related to ...", etc.)
Before:
After:
Code review checklist (for code reviewer to complete)