-
Notifications
You must be signed in to change notification settings - Fork 17
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
Can't register new Kubernetes schemas #12
Comments
Updating this to add some LSP logs. This is what follows after selecting the custom schema with "rpc.send"
{ jsonrpc = "2.0", method = "workspace/didChangeConfiguration",
params = { settings = { redhat = { telemetry = { enabled = false } },
yaml = { format = { enable = true }, hover = true, schemaDownload = { enable = true },
schemaStore = { enable = true, url = "https://www.schemastore.org/api/json/catalog.json" },
schemas = { ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.5-standalone-strict/all.json"] = "file:///Users/josh/src/joshfrench/yaml-companion.nvim/ingress.yaml",
result = {} }, trace = { server = "debug" }, validate = true } } } }
"rpc.receive"
{ id = 4, jsonrpc = "2.0", method = "workspace/configuration",
params = { items = { { section = "yaml" }, { section = "http" }, { section = "[yaml]" },
{ section = "editor" }, { section = "files" } } } }
"server_request: callback result"
{ result = { { format = { enable = true }, hover = true, schemaDownload = { enable = true },
schemaStore = { enable = true, url = "https://www.schemastore.org/api/json/catalog.json" },
schemas = { ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.5-standalone-strict/all.json"] = "file:///Users/josh/src/joshfrench/yaml-companion.nvim/ingress.yaml",
result = {} }, trace = { server = "debug" }, validate = true }, vim.NIL, vim.NIL, vim.NIL, vim.NIL }, status = true }
"rpc.send"
{ id = 4, jsonrpc = "2.0",
result = { { format = { enable = true }, hover = true, schemaDownload = { enable = true },
schemaStore = { enable = true, url = "https://www.schemastore.org/api/json/catalog.json" },
schemas = { ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.5-standalone-strict/all.json"] = "file:///Users/josh/src/joshfrench/yaml-companion.nvim/ingress.yaml",
result = {} }, trace = { server = "debug" }, validate = true }, vim.NIL, vim.NIL, vim.NIL, vim.NIL } }
"rpc.receive"
{ jsonrpc = "2.0", method = "yaml/schema/store/initialized", params = vim.empty_dict() }
"rpc.receive"
{ jsonrpc = "2.0", method = "textDocument/publishDiagnostics",
params = { diagnostics = {}, uri = "file:///Users/josh/src/joshfrench/yaml-companion.nvim/ingress.yaml" } } It looks like the client is correctly sending At this point I'm not sure if the issue is here or in |
This is most likely an issue in |
Possibly related? redhat-developer/yaml-language-server#60 |
Diagnostics break even just changing the default version in version.lua from 1.22.4 to 1.22.5. Oddly enough, all schema files are the same if you remove the version from the files ( |
I have the same problem,after some digging i believe this is due to a hard coded version in yaml-language-server itself: as workaround i "patched" the node files in the location where mason install the server:
you have to add the schema then in the config:
afterwards the validation and completion works for me, if i choose the added schema with |
The hack seems to work, thanks for looking into it. For a more future-proof hack that works with any version, you can change the conditions on line 339 and 343 of if (fileMatch.constructor === Array && uri.search(/kubernetes-json-schema/)) {
fileMatch.forEach((url) => {
this.yamlSettings.specificValidatorPaths.push(url);
});
}
else if (uri.search(/kubernetes-json-schema/)) {
this.yamlSettings.specificValidatorPaths.push(fileMatch);
}
|
hey @someone-stole-my-name local yaml_cfg = require('yaml-companion').setup {
builtin_matchers = {
-- Detects Kubernetes files based on content
kubernetes = { enabled = true },
},
schemas = {
{
name = 'Kubernetes 1.27.12',
uri = 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.27.12-standalone-strict/all.json',
},
{
name = 'Kubernetes 1.26.14',
uri = 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.26.14-standalone-strict/all.json',
},
},
lspconfig = {
on_attach = default_on_attach,
capabilities = capabilities,
cmd = { 'node', vim.fn.expand '~/Repos/yaml-language-server/out/server/src/server.js', '--stdio' },
settings = {
yaml = {
-- if these lines are commented out, there are no completions
-- schemas = {
-- kubernetes = '/*',
-- },
},
},
},
}
require('lspconfig')['yamlls'].setup(yaml_cfg) however, if I comment in those lines, I cannot get completion on any other schema since it's recognized as kubernetes. |
When I use the default k8s detection, diagnostics work as expected:
However, when I try to use a custom schema I do not get any diagnostics. I am able to select a custom schema via
:Telescope yaml_schema
but once attached, any existing diagnostics disappear and I can't seem to trigger them again.Here's my minimalized setup:
Output of
:lua =require("yaml-companion.config").options
:After running
:Telescope yaml_schema
and selectingKubernetes 1.22.5
, output of:lua =require("yaml-companion").get_buf_schema(0)
:I've also tried cloning the
kubernetes-json-schema
repo and pointing at a local path, but that didn't change anything.One slightly weird wrinkle: if I set up a custom schema pointing at
v1.22.4
to match the builtin, diagnostics work. Downgrading past that breaks them again though, so this may be a cached artifact? ¯\_(ツ)_/¯The text was updated successfully, but these errors were encountered: