-
Notifications
You must be signed in to change notification settings - Fork 247
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
best way to pass schema in nvim via LanguageClientNeovim #56
Comments
I am not familiar enough to neovim to provide a recommendation. If you can be more specific on the question we can help. |
Under the readme you have the following:
I'm guess that is to configure vscode though, is it not? |
It is not VSCode specific, if the client (neovim) sends those settings using the didChangeConfiguration call to the server YAML server will react to it. VSCode actually issues that call to initialize the configuration right after the server is started and everytime settings are changed. |
thank you so much @gorkem , I will post a minimal neovim config once I get it working. |
Seems like this will not work due to your protocol extension |
What exactly is the behavior? If providing a url for a schema through settings (via |
Here is a log of the client
In line 128 of the the rpchandler. In the following issue you will find a minimal vim environment and my test steps. |
Thanks for all the info! I'm going to take a look at this tomorrow morning and see if I can find out whats going on. |
I've spotted one difference between the VSCode trace and that one. In the VSCode params when doing the didChangeConfiguration I get:
Whereas in your didChangeConfiguration there is:
In this case yaml isn't an object itself, instead yaml.schemas is the name of the object which would make sense why the settings.yaml.schemas is failing. |
Awesome, that should help. Thank you. I will report back.
…On Sun, Mar 25, 2018, 10:02 PM Josh Pinkney ***@***.***> wrote:
I've spotted one difference between the VSCode trace and that one. In the
VSCode params when doing the didChangeConfiguration I get:
"settings": {
"yaml": {
"trace": {
"server": "verbose"
},
"schemas": {
"kubernetes": "/test.yaml"
},
"format": {
"enable": true
},
"validate": true
},
"http": {
"proxyStrictSSL": true
}
}
Whereas in your didChangeConfiguration there is:
{ "settings":
{
"yaml.schemas": {"file:///home/hurricanehrndz/.config/nvim/yaml/schemas/ansible.json":"/*.yml"}
}
}
In this case yaml isn't an object itself, instead yaml.schemas is the name
of the object which would make sense why the settings.yaml.schemas is
failing.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#56 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFiQzWOkE3Lh8d5mHxe-ONnt5OoCIv4cks5tiGhygaJpZM4St6-n>
.
|
May I ask how I can trace in vscode in case I encounter other problems,
sorry language severs is very new to me.
…On Sun, Mar 25, 2018, 10:18 PM Carlos Hernandez ***@***.***> wrote:
Awesome, that should help. Thank you. I will report back.
On Sun, Mar 25, 2018, 10:02 PM Josh Pinkney ***@***.***>
wrote:
> I've spotted one difference between the VSCode trace and that one. In the
> VSCode params when doing the didChangeConfiguration I get:
>
> "settings": {
> "yaml": {
> "trace": {
> "server": "verbose"
> },
> "schemas": {
> "kubernetes": "/test.yaml"
> },
> "format": {
> "enable": true
> },
> "validate": true
> },
> "http": {
> "proxyStrictSSL": true
> }
> }
>
> Whereas in your didChangeConfiguration there is:
>
> { "settings":
> {
> "yaml.schemas": {"file:///home/hurricanehrndz/.config/nvim/yaml/schemas/ansible.json":"/*.yml"}
> }
> }
>
> In this case yaml isn't an object itself, instead yaml.schemas is the
> name of the object which would make sense why the settings.yaml.schemas is
> failing.
>
> —
> You are receiving this because you modified the open/close state.
> Reply to this email directly, view it on GitHub
> <#56 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AFiQzWOkE3Lh8d5mHxe-ONnt5OoCIv4cks5tiGhygaJpZM4St6-n>
> .
>
|
If you install YAML Support by Red Hat in VSCode and then go into preferences look for yaml.trace.server and then change that to setting to be verbose. Then you will see all the results of whats send between the client and server! |
It seems vscode also sends a json/schemaAssociations notification after initialization. I am betting that completion doesn't work without this notification? I'm not sure if it will be feasible to use this language server with the neovim clients, without developing something to aid. |
Looking at how che does it, it seems that they launch the server with the preferences and then push the schema associations |
It shouldn't need that notification thats just used to add schemas from the package.json https://github.com/redhat-developer/vscode-yaml/blob/master/src/extension.ts#L62 Out of curiosity do you mind trying this schema. Also, is it just autocompletion not working or are things like validation not working as well? |
Good news and bad news. I suspect that the schema never gets resolved. For my vim config I'm doing the following.
As you can see completion and validation both work fine. I believe the custom schema provider is not something native the Language Server Protocol. I believe all language client wishing to implement this language server need to adhere to the custom/schema/request. If you wish, I can provide my full minimal vim config that is used for testing and steps to reproduce success or issues. For now I'm going to try and focus my efforts on debugging the schema resolution, since it seems to reference the customschemaprovider as well. |
Any way to resolve this? I hit this as well. |
I think we will have to have the client register that they support the custom schema provider feature. In this case, I will make the custom schema provider feature off by default so that clients that don't/won't need that don't get blocked. |
But in case a client doesn't have that custom extensions, can't the schema simply be loaded from disk directly by the server implementation? |
IIRC the custom schema provider is only used for when you want to add schemas programmically instead of doing it through workspace/didChangeConfiguration. Otherwise the schemas are loading normally though workspace/didChangeConfiguration which then loads the schema. |
Yes. When I did my deep dive into the code, the custom schema provider is used only when the schema definitions are defined within the ide and want to submit the schemas via the custom/schema/request from the yaml ls. Yaml ls should not crash and should continue to work without the client responding to this request. Am I to understand that you no longer need to respond to this request? @languitar |
@hurricanehrndz Tried that, but the neovim implementation still complains about those requests as being unparseable:
Anyway, why do I still need this? Why doesn't setting the configuration options work correctly? |
Setting configuration options has always worked. I never had an issue with that. The problem was always with YAML LS not doing completions if you didn't respond to the custom request. As long as you respond to the custom request completion should work, it just needs to be a blank response. I would not pass custom schema via the request, I always did that via notify. I have not tested the responding the request, but that is because the last time I used this the handler functionality of the language client did not exist. So it is up to you to test it out. You can see that here: I wrote a basic config example and everything on the wiki for the language-client: |
on why we need to respond to the request, I personally have no idea. @JPinkney had mentioned awhile ago that YAML LS would be updated to have clients report support for the custom request, so that clients who do not respond do not get blocked. Whether this has been implemented or not, only he can answer. |
Hasn't been implemented yet but I'm hoping to get to it next week. |
That would be great, because answering the custom request still doesn't work with the neovim client. The reason is that the payload of the request (
@JPinkney if you start changing things here, maybe fixing that to an object or array would also be a good idea to be consistent with the protocol specification. |
I've made it so clients have to register that they want to use "custom/schema/request". Please give the newest version a try and let me know if it works for you! |
Just starting to test this. First thing I get is:
|
Here is the complete communication up to that error:
|
I wonder if the language server is crashing because of the new settings https://github.com/redhat-developer/yaml-language-server#language-server-settings |
Looks like there is some hidden assumption about the settings always being sent to the server from the client in the initialize request. |
One I add a "format" object to the settings, this works. So there is a missing check for that object to exist. |
If I'm not mistaken everything here should be good to go now. Let me know if there are any more issues. |
I am having a hard time making the language server work with LanguageClient-neovim. After I read the comments on this issue, I configured the following. I have an {
"yaml": {
"format": {
"enable": false
},
"validate": true,
"hover": true,
"completion": true,
"schemas": {
"file:///path/to/ansible/schema.json": "/*"
}
},
"http": {
"proxyStrictSSL": true
}
} I am using this to send the above json stuff to the language server: call LanguageClient#Notify('workspace/didChangeConfiguration', { 'settings': config }) where config is the above json data. Then, I have registered a handler for call LanguageClient#registerHandlers({
\ 'custom/schema/request': 'HandleWorkspaceConfig',
\ }) and the handler simply runs:
The weird thing is that in the log generated by LanguageClient, there is no |
You shouldn't need to do |
OK. But I do not get any completions. I forgot to mention that I start the language server with:
I am getting some diagnostic feedback for malformed yaml so communication with the server does happen successfully. From the logs of the client, I see this:
|
Actually, I can't get this to work at all even with vscode. I uninstalled any manual installation of yaml-language-server (
Then, I created a new .yml file and pressed Ctrl+Space. I got no completions. I tried loading the ansible schema, but failed to get completions again. I added |
So, started from scratch and managed to get kubernetes working. These are all the custom vscode settings that I have:
Now, if I change
needs fixing because a
But even after that, no completion happens. I guess there is sth wrong with the schema file? |
For http://json.schemastore.org/ansible-stable-2.5 schema you need to start with a - and then a space and then you should getting completions. If you get completions/hover/schema validation at least once then that means the schema is setup correctly. If you're getting further issues that look to be schema issues you can report them here |
OK, I think I am finally getting somewhere. Sincere thanks for your help and even more you patience. 🙇♂️ |
Just wondering what would be the best way to define new schemas using neovim and LanguageClient
The text was updated successfully, but these errors were encountered: