diff --git a/docs/source/pages/advanced_usage.rst b/docs/source/pages/advanced_usage.rst index 2a7de463..cbedfd3f 100644 --- a/docs/source/pages/advanced_usage.rst +++ b/docs/source/pages/advanced_usage.rst @@ -488,7 +488,8 @@ Workspace methods that can be used for user defined features are: def apply_edit(self, edit: WorkspaceEdit, label: str = None) -> ApplyWorkspaceEditResponse: # Omitted - + def apply_edit_async(self, edit: WorkspaceEdit, label: str = None) -> ApplyWorkspaceEditResponse: + # Omitted .. _pygls.lsp.methods: https://github.com/openlawlibrary/pygls/blob/master/pygls/lsp/methods.py .. _pygls.lsp.types: https://github.com/openlawlibrary/pygls/tree/master/pygls/lsp/types diff --git a/pygls/protocol.py b/pygls/protocol.py index 7e9ac306..28b7d907 100644 --- a/pygls/protocol.py +++ b/pygls/protocol.py @@ -742,6 +742,14 @@ def apply_edit( WORKSPACE_APPLY_EDIT, ApplyWorkspaceEditParams(edit=edit, label=label) ) + def apply_edit_async( + 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) + ) + @lsp_method(EXIT) def lsp_exit(self, *args) -> None: """Stops the server process.""" diff --git a/pygls/server.py b/pygls/server.py index 605a021e..4993ad87 100644 --- a/pygls/server.py +++ b/pygls/server.py @@ -378,6 +378,12 @@ def apply_edit( """Sends apply edit request to the client.""" return self.lsp.apply_edit(edit, label) + def apply_edit_async( + self, edit: WorkspaceEdit, label: Optional[str] = None + ) -> WorkspaceApplyEditResponse: + """Sends apply edit request to the client. Should be called with `await`""" + return self.lsp.apply_edit_async(edit, label) + def command(self, command_name: str) -> Callable[[F], F]: """Decorator used to register custom commands.