extend and add autocompletion for Particular YAML file based on custom schema
Answered
I am looking for some input on how to add autocompletion to a YAML file with particular name using custom plugin.
We have custom schema or allowed attributes in YAML format.
Please sign in to leave a comment.
You could try to implement the `JsonSchemaProviderFactory` Extension Point and `JsonSchemaFileProvider` interface. It works both for Json and Yaml.
Thanks for providing your input it helped me to progress.
What is the recommended way to apply config in my plugin where this schema get applied to only particular file based on name / pattern ?
I could do this using code in implementation of JsonSchemaProviderFactory.
Also when there is a schema error how to configure so IDE displays those line as errors ?
Yes, the `VirtualFile` class gives you access to the filename and directory, also you can use the `VirtualFileSystem` service to convert it to `java.nio.file.Path` for instance. If you can determinate the schema without loading the file content - it is great! So your implementation of `isAvailable` is one of the example of how it can be done.
> Also when there is a schema error how to configure so IDE displays those line as errors ?
It should be done automatically once IDEA matches the file and it's schema, it is done by the "YAMLSchemaValidation" inspection implemented by class `YamlJsonSchemaHighlightingInspection`