✨ Snippets
nanashili opened this issue · 17 comments
Absolutely! Here are a few considerations...
- We need to figure out how we will create and store user defined snippets.
- Extensions will also be able to add snippets.
- Users should also be able to type a string of characters in the editor and auto suggest should suggest the associated snippet.
- When pressing tab it is inserted with the first wildcard highlighted if applicable.
- Snippets should also be aware of the file it is in so it can be auto-populated.
We can use a local database maybe or something similar.
When highlighting the code we can right click to add to snippets
I might suggest storing them in a JSON file like VS Code, https://code.visualstudio.com/docs/editor/userdefinedsnippets. The same code can then also be used by snippet extensions written by developers and shared on the "marketplace".
It's important that these files can be easily backed up automatically by CodeEdit or that they are in a straightforward location so that they can easily be added to other computers and shared.
I might suggest storing them in a JSON file like VS Code, https://code.visualstudio.com/docs/editor/userdefinedsnippets. The same code can then also be used by snippet extensions written by developers and shared on the "marketplace".
It's important that these files can be easily backed up automatically by CodeEdit or that they are in a straightforward location so that they can easily be added to other computers and shared.
I was thinking json too but wasn't to sure if it would work but since it does it would suggest json because it can provide a lot of performance enchantments
@jasonplatts that is a good resource! We might be able to find code that will help us to parse the json and process the variables specified in that documentation link.
Lots of good stuff there to help with the extensions API too @austincondiff. If we can keep the process of extension development similar, we should be able to port a lot over and encourage devs to contribute.
@jasonplatts We should at some point reach out to extension developers of other platforms and see if they can A) help us with the extension API, and B) help us write extensions.
I'm currently working on the design of it.
For sure! I've reached out to some already and I have a few others in mind too. If anyone is able to themselves contribute or knows of anyone else who might be interested, please spread the word! This issue, #76, provides a general overview.
We can have a basis of it already by select code in the editor and then saving it. Will most like push it once we have a custom editor
I'm currently working on the design of it.
Thanks for your contributions and hard work! I am also trying to get into the details of the API. It's work in progress, but please feel free to add to the list that is started here, #76.
Here is a template of the Snippets View
Screen.Recording.2022-03-23.at.13.21.48.mov
@jasonplatts Why don't we save the basic information of the snippets in the json like name, description, method, platform and completion then the code we add it to it's respective file so if the code is java it would be snippet_name.java and then add the path of the file in the json?
I was thinking more along the lines of using the same setup as VS Code, where we store all of the snippet code in JSON format. We could have a global JSON file that stores snippets that should appear for all languages and then separate language-specific JSON files, such as javascript.json, php.json, etc. This way there would be no need to link to other files from a JSON. CodeEdit would only need to read all JSON files from a directory and load those that are necessary.
There would be a couple of benefits. First, we only have to worry about reading in JSON files rather than different language specific files. Second, we could then offer consistent snippet syntax, VS Code Snippet Syntax, regardless of the language. This includes tabstops, placeholders, for example. Third, this makes it easier for developers to import their existing VS Code snippets. It would even be possible to offer an import VS Code Snippets option.
Thoughts?
I was thinking more along the lines of using the same setup as VS Code, where we store all of the snippet code in JSON format. We could have a global JSON file that stores snippets that should appear for all languages and then separate language-specific JSON files, such as javascript.json, php.json, etc. This way there would be no need to link to other files from a JSON. CodeEdit would only need to read all JSON files from a directory and load those that are necessary.
There would be a couple of benefits. First, we only have to worry about reading in JSON files rather than different language specific files. Second, we could then offer consistent snippet syntax, VS Code Snippet Syntax, regardless of the language. This includes tabstops, placeholders, for example. Third, this makes it easier for developers to import their existing VS Code snippets. It would even be possible to offer an import VS Code Snippets option.
Thoughts?
We could do that yes, but we also have to be aware of the size of json because it could end up causing performance issues for users that save a lot of snippets.
I agree. That is definitely a valid concern.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.