Closed mcritchlow closed 2 years ago
Thanks for reporting! This isn't an issue with SchemaStore.nvim, but it is an important behavior that I should describe in the documentation.
This is due to the way jsonls
handles its configuration, which is a bit counter-intuitive IMO. It seems that if you pass settings = { json = { ... } }
, jsonls
treats any unspecified option as false
, rather than using the default value that would be used if you didn't pass any settings. The option that is causing your issue is validate.enable
. To fix this, you can explicitly enable the validate
option:
nvim_lsp.jsonls.setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
json = {
validate = { enable = true },
schemas = require("schemastore").json.schemas(),
},
},
})
For reference, here is the jsonls
code causing this issue: https://github.com/microsoft/vscode/blob/6fef251f8f0e9f74b7adb4ed310e35eabb97afdf/extensions/json-language-features/server/src/jsonServer.ts#L230-L239
validateEnabled
is true
by default, but if any of the settings are changed, it defaults to false
.
If you wanted, you could open an issue there and suggest that the default values should be kept if the settings doesn't include a certain key. They have over 6k open issues, though, so I have my doubts that it would be fixed any time soon.
Ah, that's so helpful, thank you! I definitely agree that it's counter-intuitive to flip default settings when another setting is changed.. But that definitely addresses the issue on my end. Again, much appreciated :)
Hi,
Apologies if this is the wrong repo to report this too, but I've narrowed down nvim not showing diagnostics for json files to the configuration used to reference the schemastore json schemas.
Specifically, adding this to the lsp
setup
stops diagnostics from rendering in nvim (though I do see them in the LSP log if I usedebug
)lsp log:
minimal
init.lua
(borrowed from lspconfig and modified for this issue)