haskell / lsp

Haskell library for the Microsoft Language Server Protocol
360 stars 89 forks source link

Allow registering multiple handlers for a notification #520

Open michaelpj opened 10 months ago

michaelpj commented 10 months ago

At the moment we only allow one handler per method. This is partly because it's unclear how we could respond to a request if we have multiple handlers (HLS has stuff to allow that, but it's complicated and I don't think we want it in here). But it's perfectly fine to have multiple handlers for a notification.

This would simplify part of our processing system. At the moment we intercept certain notifications in order to update our state before then calling the registered handler. But if we could have multiple handlers, then we could just install our own handler to update our state, and have it coexist with any user-provided handlers.

This would also simplify the situation if the user doesn't want to respond to those notifications. At the moment, they need to install a (possibly-empty) handler, otherwise they get errors about there being no handler!