First draft of server side snippets #209
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the first draft of server side snippet support.
The basic idea is that we want the snippets to produce valid yaml without or with a schema involved. In the first case, without a schema, it's pretty simple. You can just ask the user who is adding/creating the snippet which context that the snippet should appear in:
and then when you are performing auto completion you can determine the context of your current cursor position and grab a list of snippets associated with that context.
Showing snippets when you have a schema associated with the yaml file is a lot more complicated. This is because you have to determine whether the snippet matches the context of the schema and the context of the autocompletion.
E.g. if you want a snippet for "{hello: $1\ngoodbye: $2}" we need to determine what we are inserting is an object and then that also matches up with an object in the schema. You would then need to check if additionalProperties is true or false in the schema and if the resulting 'hello' and 'goodbye' are in the properties of the object.
When a schema is associated with a yaml file you need to make sure whatever snippet you insert doesn't lead the yaml file to have an error