-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support custom request and notification handlers #44
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-handler
and:notification-handler
options, 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-handler
instead ofwith-redefs
.