Support custom request and notification handlers#44
Support custom request and notification handlers#44ferdinand-beyer wants to merge 3 commits intoclojure-lsp:masterfrom
Conversation
mainej
left a comment
There was a problem hiding this comment.
Would you update the Receive messages section of the README to describe how to use the custom handlers?
As you do so, would you explain how the custom handlers should deal with requests or notifications that they don't know how to handle?
They have a few options. They can either return :lsp4clj.server/method-not-found, in which case lsp4clj will arrange to log the message and, in the case of requests, reply to the client with a not-found response. Or they can do these tasks themselves.
|
@mainej -- Done. Will you please review these? You are better with words than I am :) |
mainej
left a comment
There was a problem hiding this comment.
Looks good! Optional, but it might be nice to include the middleware example in the README.
- allows multiple server instances that don't compete on implementing the multi-methods - allows ring-style middleware
6542e47 to
0cdb5b0
Compare
|
Added a middleware example to the README and added |
This PR allows users to specify custom handler functions instead of the
receive-*multi-methods.The main reason for that is to enable middleware, e.g. to log/time/trace requests, execute them on different threads, etc. Using the
:request-handlerand:notification-handleroptions, one could create Ring-style middleware:Avoiding global state in the multi-methods also allows having multiple LSP implementations on the classpath. Not a common use case, but we found ourselves in the situation where we had both
clojure-lsp(to use the linter) and our custom LSP on the dev classpath.Some tests could now be simplified, using
:request-handlerinstead ofwith-redefs.