Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First draft of server side snippets #209

Closed
wants to merge 1 commit into from
Closed

Conversation

JPinkney
Copy link
Contributor

@JPinkney JPinkney commented Dec 9, 2019

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:

export enum SnippetContext {
  any = 'any',
  scalar = 'scalar',
  object = 'object',
  array = 'array'
}

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

@gorkem
Copy link
Collaborator

gorkem commented Dec 30, 2019

Should we conclude #157 before completing this one?

@JPinkney
Copy link
Contributor Author

JPinkney commented Jan 2, 2020

@gorkem Yeah, #157 will be finished first

@JPinkney
Copy link
Contributor Author

This can be closed as defaultSnippets has been implemented, allowing you to specify snippets that via json schema!

@JPinkney JPinkney closed this Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants