Add support for dynamic capability registration for the diagnostic
pull model to support Pyright >= 1.1.407 and other language servers.
This is a rather complex and intricate change tested with Pyright and
gopls, and may need further tweaking if something breaks with another
server.