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

✨ Snippets #167

Closed
nanashili opened this issue Mar 22, 2022 · 18 comments
Closed

✨ Snippets #167

nanashili opened this issue Mar 22, 2022 · 18 comments
Labels
enhancement New feature or request extensions Issues related to the extension architecture in CodeEdit wontfix This will not be worked on

Comments

@nanashili
Copy link
Contributor

Describe the solution you'd like
Do we want to add something like the Snippets action from Xcode where users can save snippets of their code and use it later or in the future.

Additional context
Screenshot 2022-03-22 at 17 41 13

@nanashili nanashili added the enhancement New feature or request label Mar 22, 2022
@austincondiff
Copy link
Collaborator

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.

@nanashili
Copy link
Contributor Author

We can use a local database maybe or something similar.

When highlighting the code we can right click to add to snippets

@jasonplatts
Copy link
Collaborator

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.

@nanashili
Copy link
Contributor Author

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

@austincondiff
Copy link
Collaborator

@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.

@jasonplatts
Copy link
Collaborator

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.

@austincondiff
Copy link
Collaborator

austincondiff commented Mar 22, 2022

@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.

@nanashili
Copy link
Contributor Author

I'm currently working on the design of it.

@jasonplatts
Copy link
Collaborator

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.

@nanashili
Copy link
Contributor Author

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

@jasonplatts
Copy link
Collaborator

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.

@jasonplatts jasonplatts added the extensions Issues related to the extension architecture in CodeEdit label Mar 22, 2022
@nanashili
Copy link
Contributor Author

Here is a template of the Snippets View

Screen.Recording.2022-03-23.at.13.21.48.mov

@nanashili
Copy link
Contributor Author

@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?

@jasonplatts
Copy link
Collaborator

jasonplatts commented Mar 23, 2022

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?

@nanashili
Copy link
Contributor Author

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.

@jasonplatts
Copy link
Collaborator

I agree. That is definitely a valid concern.

@jasonplatts jasonplatts changed the title [FEAT] - Snippets [FEAT] Snippets Mar 23, 2022
@austincondiff austincondiff changed the title [FEAT] Snippets ✨ Snippets Mar 31, 2022
@stale
Copy link

stale bot commented May 30, 2022

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.

@stale stale bot added the wontfix This will not be worked on label May 30, 2022
@austincondiff austincondiff moved this from 🆕 New to 🏁 Complete in CodeEdit Project Feb 14, 2023
xinix909 pushed a commit to xinix909/CodeTransfer that referenced this issue Sep 7, 2024
@austincondiff austincondiff reopened this Dec 11, 2024
@github-project-automation github-project-automation bot moved this from 🏁 Complete to 📋 Todo in CodeEdit Project Dec 11, 2024
@github-project-automation github-project-automation bot moved this from 📋 Todo to 🏁 Complete in CodeEdit Project Dec 11, 2024
@austincondiff
Copy link
Collaborator

Closed in favor of #1623

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request extensions Issues related to the extension architecture in CodeEdit wontfix This will not be worked on
Projects
Status: 🏁 Complete
Development

No branches or pull requests

3 participants