-
Notifications
You must be signed in to change notification settings - Fork 92
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
Server implementations should have a way to modify ServerCapabilities directly #517
Comments
I'm also beginning to bump into this issue with semantic token legends. In this case the server-supplied legend needs to be chosen based on the client capabilities, and then stored somewhere for use when calling The simplest change I can think of to enable this would be:
The main ugliness here is that that the signature of |
So the way I'm currently thinking of approaching this is a bit bigger, namely via #583 But I think there's an intermediary state that would help, namely:
I think this pushes us in the right direction and would let people set up the I'm in the middle of something else, but I'd welcome a PR for that change, I think it should be fairly localised! |
Ahh, sorry! Had seen that issue, but hadn't quite thought about how it might relate to this one. With this change, are you proposing removing all the capability-related information from |
Hmm yes, I think we could basically get rid of |
Great, thanks!
There's a couple of options (server info, progress delays), which aren't part of server capabilities. Those could stay as-is, or be merged into |
Yes, those make sense to stay as options indeed. |
Sorry for the lack of updates. I've a branch which makes this change, but having done so, I'm now less sure it makes sense in isolation from #583. The main pain point here is that |
Yeah, it's definitely less fun to work with |
So you could write a lens (or traversal) that promotes the boolean to the full options1. For example (excuse the terrible names): newtype ServerCapabilities' = ServerCapabilities' { unServerCapabilities' :: ServerCapabilities }
serverCapabilities :: Lens' ServerCapabilities' ServerCapabilities
serverCapabilities = lens unServerCapabilities' (const ServerCapabilities')
instance L.HasCodeActionProvider ServerCapabilities' (Maybe CodeActionOptions) where
codeActionProvider = serverCapabilities . lens get set where
get caps = case caps ^. L.codeActionProvider of
Nothing -> Nothing
Just (InL False) -> Nothing
Just (InL True) -> Just $ CodeActionOptions Nothing Nothing Nothing
Just (InR opts) -> Just opts
set caps val = caps & L.codeActionProvider .~ (InR <$> val) Footnotes
|
Right, and also for some of the others we should have sub/supertype lenses: #589 There are a few things I think we also need to express:
Then maybe we can have some optic that turns a big |
At the moment we infer the
ServerCapabilities
from theHandlers
andOptions
. The only way for servers to alter the capabilities that we infer is if we provide a handle for doing that viaOptions
. In some ways that's nice and discoverable, but it might be easier just to let the server directly modify the inferredServerCapbilities
before we send it back.In many cases I think it would just be fiddly to expose things via
Options
. For example, most server capabilities for methods allow you to opt-in to client-initiated progress. At the moment we just always disable that and rely on server-initiated progress, but it would be reasonable for a server to want to opt in... but even then you probably only want to do it for certain methods. So we could have amethodsToOptInToClientInitiatedProgress
option... or we could just let the server modify theServerCapabilities
.The text was updated successfully, but these errors were encountered: