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

Add code snippets #6

Open
NathanLovato opened this issue Jan 15, 2020 · 10 comments
Open

Add code snippets #6

NathanLovato opened this issue Jan 15, 2020 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@NathanLovato
Copy link
Collaborator

Add code snippets or skeletons for GDScript.

I use yasnippet, that's really powerful, but should snippets for this package be included here? Split to another package?

Should I use the emacs skeletons? Abbreviations? Both? As these features are included in Emacs itself.

Feedback is welcome!

@NathanLovato NathanLovato added enhancement New feature or request help wanted Extra attention is needed labels Jan 15, 2020
@NathanLovato
Copy link
Collaborator Author

NathanLovato commented Jan 15, 2020

The reason I like to use yas is that you can use code and conditions in the snippets. This way, if the user wants to code with type hints, the snippets could have optional type hints.

Also, you can easily have things like creating a setter and/or a getter function along with a variable.

@NathanLovato
Copy link
Collaborator Author

Some snippet ideas:

  • variables: simple, constant, onready, exported
  • var with setter
  • var with getter
  • var with setter and getter
  • void function
  • static function
  • yield on an on-the-fly timer: yield(get_tree().create_timer(1.0), "timeout")
  • function call with yield, waiting for function to complete: yield(some_func(), "completed")

@PinyaColada
Copy link

and also estructures like an if, if-else, if-elif-else, while, for etc... That would be great!

@Calinou
Copy link
Member

Calinou commented Oct 14, 2020

@PinyaColada An if or a while statement only has minimal boilerplate (a keyword and a punctuation sign). Is a snippet really useful at this point?

@NathanLovato
Copy link
Collaborator Author

The simpler statements aren't too useful, yes. Maybe they can be there for the sake of providing a consistent experience. The if template is a little too basic but as you can autocomplete all snippets as you type with yas, if you know you have all basic keywords supported, you can type quite a bit of code using the same keyboard shortcuts.

Although I don't know how you'd make if/else and if/elif/else work efficiently as one snippet. I'd rather have one for each, so you insert if, elif, or else lines as needed.

1 similar comment
@NathanLovato
Copy link
Collaborator Author

The simpler statements aren't too useful, yes. Maybe they can be there for the sake of providing a consistent experience. The if template is a little too basic but as you can autocomplete all snippets as you type with yas, if you know you have all basic keywords supported, you can type quite a bit of code using the same keyboard shortcuts.

Although I don't know how you'd make if/else and if/elif/else work efficiently as one snippet. I'd rather have one for each, so you insert if, elif, or else lines as needed.

@NathanLovato
Copy link
Collaborator Author

Also I'd prefer yasnippet after spending some time with it, because it supports much more stuff than alternatives. For instance, we can optionally include type hints in snippets.

@xiliuya
Copy link
Collaborator

xiliuya commented Apr 24, 2023

I thought maybe use the yasnippet-snippets package and submit spnippet in gdscript-mode.

@NathanLovato
Copy link
Collaborator Author

That'd probably be the way to go! Feel free to close this.

@xiliuya
Copy link
Collaborator

xiliuya commented Apr 24, 2023

Currently, the requirements listed above are not fully supported, so they will not be closed . ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants