-
Notifications
You must be signed in to change notification settings - Fork 216
Maybe use initializationOptions as additional source of settings #195
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
Comments
It doesn't really make sense for this server to read its settings from It sounds like you are suggesting to add extra code and complicate the project because of particular client's limitation/deficiencies (not supporting |
Makes sense but IMO an LSP client should not need to know whether an option is required early during initialization. |
I don't think that LSP is vague here. The protocol defines And a generic client implementation can never know what settings a particular server expects. It should be always up to the server-specific configuration defined separately from the generic client implementation to define which options to pass where. It's wrong for a generic client implementation to assume that both of those accept the same set of options. |
OK, not vague but "requires knowledge of servers to implement rcorrectly". So there are three different configuration options |
The |
At the risk of reopening old wounds :-), it seems typical for language servers to send At the moment, I've got a customer who can't configure So if it's practical to send a |
@siegel, thanks for your feedback. If this requires only sending |
@ccordoba12 Thanks! I appreciate your willingness to adopt a change. I regret that the work is outside of my expertise; I am a consumer of the server, but know nothing about its internals (nor, alas, would I feel comfortable trying to learn the internals in any reasonable amount of time). But if anyone else feels comfortable making the necessary change, then I am delighted to test it when it gets merged and released. |
Ok, I have no problem with that, but since this doesn't directly benefit us (i.e. it's a feature we won't use in Spyder), it'll go to the backlog of things I have to do. So, this could take a long time to be solved. However, you said:
So, since this is for a paid job, I'd say that if you're willing to make a good donation to our Open Collective, then I'd take a look at it sooner (two or three weeks). If you're interested, please send me an email (it's in my profile) to discuss the details. |
I'm not getting paid for this. :-) However, the customer has expressed an interest in working on this themselves, so they may be submitting a PR at some point. |
Hi @ccordoba12! I’m the customer in question. For clarity, my end goal is to use:
I’d be more than happy to take a crack at this. After digging through the code, though, I’m not entirely sure where would be the right place to start. My hypothesis (feel free to laugh!) would be that it would look something like:
Alternatively, BBEdit already supports workspace-specific configuration. That seems like an ideal and broadly useful feature for pylsp. |
That's a very client-specific feature; I don't know if it makes sense for the server to implement it. But others may know better than I. :-) |
Think you misunderstood that. Settings specified in this custom BBEdit configuration will just be communicated to the server using standard LSP requests ("Initialization Options" through intialize request and "Workspace-Specific Configuration" through Not sure as I haven't checked the code but I think this whole issue boils down to |
Yep, that's exacly what I thought too. If there are clients (like BBEdit) that don't send |
@kstrauser, you said:
As I said before, I'd be willing to give you a hand if you'd like to make a donation to Spyder (I'm the lead Spyder maintainer and also maintain this project because it's the Python server we use in Spyder). If not, you can study our code and the LSP protocol and try to make a PR for it. For us this is quite low priority because we don't use this functionality in Spyder. So, I could take a look at it in a year or so (I have tons of other things to do, sorry).
You're quite right! That's exactly how this should work. |
First, thanks for everyone involved having taken the time out of your days to discuss this. I appreciate it! @ccordoba12 I'm willing to have that discussion. Full disclosure: this is something I'd like for my personal use, because it's been a recurring pain point with other editors, too. Today we're specifically talking about me wanting to configure BBEdit, but I'd run into the same problem with Emacs, Nova, and other editors. (What can I say? I'm fickle and editors are my Pokemon -- I've gotta catch them all!) It's easy enough to configure plugins like flake8 and pycodestyle, but python-lsp-ruff had me banging my head against the wall. I'd love to be able to configure a ball of JSON in my editor, toss it to pylsp, and have everything just work. To that end, I'll put my money where my mouth is. Again, this is for my personal use. My budget -- and my spouse with whom I share a checking account -- won't allow me to send you on a nice vacation. If you don't think this would take much work, and lunch or a pizza for the office or something like that would make it worth your effort, let's make this happen! And if not, no hard feelings. I appreciate the awesome project you've worked hard on! In fact, let me know if there's a way I can send you some coffee/beer/sparkling-water money. |
Great! My email is in my profile, so just send me one and we'll start talking about it.
Don't worry, I'm not expecting that.
I think this shouldn't be that difficult, so a relatively small donation should be enough.
Thanks for your kind words!
I don't have an account for something like that, but you could still donate to our Open Collective. |
Done, and done! |
I haven't heard back about my offer of paid work, so I presume this isn't still an available option. |
Re-posting my comment here since this is the better room to discuss this. I feel the discussion around Language servers need to be configurable dynamically, especially when they run on a separate VM.
|
Unfortunately there is no indexing workflow for LSP (microsoft/language-server-protocol#54). Since we are free to define initializationOptions: {
settings: typeof DidChangeConfigurationParams.settings,
/ * place reserved for other initialization-specific settings to be added in the future */
} A similar pattern is used by some other servers but naming varies, e.g. LLVM users I think that this should be fixed at the spec level because otherwise we are back to n-m problem which LSP was supposed to solve. I would be much more inclined to approve a PR if there was a blessing from the LSP spec team on going one way or the other. |
@krassowski I am curious: is there a protocol around how to name features? I'm wondering if we follow some spec that defines that every feature should always have an Also, while I do see the n-m problem, I don't think it's thad bad in our case. |
@tkrabel-db With #459, I can now configure pylsp from within BBEdit. I can't tell you how happy this makes me. Thank you! |
Having a child "settings" object within the "initializationOptions" feels a bit redundant give how the meaning of "settings" and "options" is more or less the same.
I'm not sure how could the spec fix it. The options/settings are always server specific and the client has to know them before server is initialized. The best I can think of is having a common way of declaring settings schema and bundling that with the server but that still would have to be somewhat separate from the server itself. |
Given that adding this will help to solve concrete use cases (i.e. what @tkrabel-db and @kstrauser want to achieve) and it doesn't represent a significant change for the way editors/IDEs that support this server configure it, I'm +1 on including support for it in our next version. It's unfortunate that the LSP spec is unclear about how |
A huge thank you to everyone who helped with this! |
This came up in this issue with the kak-lsp client.
Before the workaround for that issue, kak-lsp sent server configuration via the
initialize
request (ininitializationOptions
).It only sent
workspace/didChangeConfiguration
when the configuration actually changed.This caused problems because pylsp ignores
initializationOptions
. The workaround is to re-send options withworkspace/didChangeConfiguration
.I wonder if it's a good idea to use
initializationOptions
as additional settings source.I see two possible variants:
initializationOptions
but letworkspace/didChangeConfiguration
override its settingsworkspace/didChangeConfiguration
arrives, forget theinitializationOptions
Annoyingly, option 2 would not have fixed the kak-lsp issue, because kak-lsp used to an empty
settings object in
workspace/didChangeConfiguration
(but that's an issue on our side).It's probably also fine to leave it; LSP is quite underspecified about how these requests interact. I heard that both are deprecated in favor of
workspace/configuration
..The text was updated successfully, but these errors were encountered: