Closed williamboman closed 1 year ago
Alternatively, maybe the require('schemastore').{yaml,json}.schemas()
functions could accept additional schemas as an option, to abstract these operations away. Something like:
local extra_schemas = {
{
description = 'My Custom JSON schema',
fileMatch = { 'foobar.json', '.foobar.json' },
name = 'foobar.json',
url = 'https://example.com/schema/foobar.json',
},
}
require('lspconfig').jsonls.setup {
settings = {
json = {
schemas = require('schemastore').json.schemas {
extra = extra_schemas,
}
validate = { enable = true },
},
},
}
require('lspconfig').yamlls.setup {
settings = {
yaml = {
validate = true,
schemas = require('schemastore').yaml.schemas {
extra = extra_schemas,
}
}
}
}
I struggled for a while to get the YAML language server to pick up my custom schema as I was providing the same structure as to the JSON language server. However, as the YAML language server expects a
{ url = fileMatch }
this was not working. I figured it'd be helpful for others to include this in the README.I also believe #9 can be closed now because there's already a
require('schemastore').yaml.schemas()
function!