CircleCI-Public / circleci-yaml-language-server

The official language server for CircleCI YAML configuration files
Apache License 2.0
20 stars 18 forks source link

Neovim - client.request commands for setToken and setSelfHostedUrl result is nil #285

Closed tomoakley closed 7 months ago

tomoakley commented 7 months ago

I have implemented the functionality for setting the Circle user token and self-hosted URL in my neovim plugin, PR here. Annoyingly I am unable to test it because the Circle org I work on has no private contexts/orbs and it's not self-hosted.

However I'd just like to check I've done it correctly; when the client.request command is made, the handler callback in the Lua code has two params - error and result (and ctx and config). According to the Neovim LSP docs, error is nil if the request completed. And result should be defined - if it's nil the request failed. When the LSP client attaches when I run it, both these are nil. The Microsoft docs for language servers say this shouldn't be the case.

In the third param in the handler callback (ctx), it contains the arguments supplied (ctx.params.arguments). These arguments contained the user token and self-hosted URL.

Does my code work? Should the Circle LSP be responding with some result to indicate success - or is it enough that error is nil? I looked at :LspLog in neovim but it doesn't appear to be sending anything. Are there any other logs I can look at for the Circle LSP?

JulesFaucherre commented 7 months ago

Hey @tomoakley, I just opened a PR to make the returns more pertinent. That being said with the current implementation, it's in fact unclear whether the command succeeded or failed so you may just want for these changes to be released. Thanks for raising this :D!

tomoakley commented 7 months ago

Awesome, thanks Jules. I will merge my PR now and when a new version is released will check it out. Thanks!

JulesFaucherre commented 7 months ago

FYI, looking at the Microsoft docs, it makes sense to return nil in case of success, as there is nothing to return here, we'll keep returning nil when the command succeeds but you'll be ensured that you'll get an error if any error happens.

JulesFaucherre commented 7 months ago

Hey, closing the issue as the version is now released.