I've got a project with some relatively complicated .json
file structure, and it's kind of pain to recall this structure, when I always need to reference another files to do it right. So I try to research this problem and find out that there are some solutions.
As I'm using coc.nvim for autocomplete, there is coc-json extension that should do what I want. At least documentation says it should. But after several hours of attempts I've got no result. Documentation is very poor, and absolutely no examples to reference to.
Some general words about structure I need to validate. All desired .json files contained in certain directory, they should be validated, but no other json outside of this directory. Filenames don't have any distinct patterns or suffixes, except for directory. Files themselves are arrays of objects.
From documentation FAQ:
How to add custom schema definitions/properties?
You have two choices:
use $schema in your json.
create json schema file and then configure json.schemes in your coc-settings.json, check out https://github.com/neoclide/coc-json/blob/master/package.json#L55
One of the described options is to use "$schema" field in JSON root, and this works in general. But as our file root is array, there is no way to specify $schema in it. To the next option.
Create json schema - easy, done. "configure json.schemes in your coc-settings.json" - how? What should be in it? package.json
line 55 is referenced, and this line unrelated to schema as far as I can tell. There is 'json.schemas' field a little further with some JSON schema in it. What should I do with it? Ok, may be this schema describes structure of json.schemas
in coc-settings.json
. Several attempts - nothing. Let's try to copy this package.json
part into project - no result after next hour of attempts.
There is one more mention of this problem in github issues section, but as far as I can tell, the answer references the approach above.
And even if above approach would succeed, it's a global setting. And I don't really need this schema anywhere beyond one project and one it's directory.
Also I've downloaded Vision plugin, but without settings it does nothing and really slows down vim.
Is there some examples of working setup? Or some more explanations on how to do it?