LSP icon indicating copy to clipboard operation
LSP copied to clipboard

Provide an optional response handler in LspExecuteCommand

Open ayoub-benali opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. I would like to extends LspExecuteCommand in order to send a workspace/executeCommand but LspExecuteCommand simply logs the response. In my case I have to open a file URI that is in the reponse.

Describe the solution you'd like LspExecuteCommand should provide an optional response handler. When missing simply log the response as the case now. Otherwise delegate the response handling.

Describe alternatives you've considered The current alternative is to copy LspExecuteCommand logic.

ayoub-benali avatar Nov 22 '21 13:11 ayoub-benali

Sounds like an easy PR. Move https://github.com/sublimelsp/LSP/blob/acfd6406ba4680a0e537dc87a72aa5b410a154e7/plugin/execute_command.py#L42-L47 to a new method on_result_async(self, response) that the plugin will be able to override.

rchl avatar Nov 22 '21 21:11 rchl

There was this PR that added on_server_response_async https://github.com/sublimelsp/LSP/pull/1992

    def on_server_response_async(self, method: str, response: Response) -> None:
        """
        Notifies about a response message that has been received from the language server.
        Only successful responses are passed to this method.
        :param    method:    The method of the request.
        :param    response:  The response object to the request. The response.result field can be modified by the
                             plugin, before it gets further handled by the LSP package.
        """
        pass

Will it suite your usecase?

predragnikolic avatar Aug 16 '22 08:08 predragnikolic

Would be kinda weird and hard to follow a code that executes a command in one place but handles the result in a completely different place. So I think this simple change would still be better.

rchl avatar Aug 16 '22 08:08 rchl