Skip to content

Add new snippets and fix descriptions for others #17

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

Closed
wants to merge 1 commit into from
Closed

Add new snippets and fix descriptions for others #17

wants to merge 1 commit into from

Conversation

hugo-vrijswijk
Copy link
Contributor

I've added some new snippets as the current ones did not seem that useful.

I'm not sure if the proposed set of snippets are ideal, so I think it'd be great to have some discussion about what would make a great snippet experience for Scala!

@olafurpg
Copy link
Contributor

Thank you for this contribution! I agree it would be good to start a discussion on what makes a great snippet experience. My personal take on what makes a good snippet

  • only one placeholder, it's confusing to step through multiple placeholders with tab
  • few false positives, it's annoying for example if writing "cl" inside a local block suggests to declare a class.
  • the snippet saves you a non-trivial number of keystrokes. It's sometimes faster to type out "trait Name {}" instead of "trName".

From these principles, one snippet that checks all boxes is "def main".

@hugo-vrijswijk
Copy link
Contributor Author

hugo-vrijswijk commented Mar 25, 2019

Hmm, good points! I agree the main point should be to save boilerplate typing, but also smaller tasks that the user will just be doing very often. Unfortunately Scala is quite concise, so there are no 'obvious' large boilerplate things to have.

I think a good starting place could also be the IntelliJ Live Templates for Scala (views easier in IntelliJ), and the TypeScript snippets for VS Code

few false positives, it's annoying for example if writing "cl" inside a local block suggests to declare a class.

Ideally, yes. But I don't think you can make snippets smart enough for that. As you can also create a class inside a class, but not inside a function. I think the user will just have to be smart enough not to do it by themselves (same with main in a class instead of object, for example).

only one placeholder, it's confusing to step through multiple placeholders with tab

Not sure if I agree with this. It's quite common for snippets to have a couple of variables. The placeholders are highlighted, and to me tabbing through them is fairly natural. And as the Scala snippets extension is separate from syntax highlighting, the user will have made a conscious choice to install more snippets. I agree we shouldn't go overboard though. That said, I think the 'val' and 'implicit class' placeholders are a bit much on either end of the spectrum, so I'll remove them.

Lemme know what you think. I suggest adding these snippets as well:

  • case class (cc?)
  • for
  • for yield (fory?)
  • ifelse (without brackets by default?)
  • map (similar to TypeScript foreach)
  • apply
  • unapply

@nicolasstucki
Copy link
Contributor

After discussions at a Scala Center meeting, the following conclusion was reached the conclusion

  • snippets extension should be removed, leave it to community to maintain. It's OK to install multiple snippet extensions so it's fine to have multiple competing community extensions.
  • syntax rules stays in the repo because it's not possible to have a multiple Scala syntax extensions.

@nicolasstucki
Copy link
Contributor

@hugo-vrijswijk as you have great ideas for the snippets, I would suggest you create a for of this project and publish a version of the snippets with all your updates.

@nicolasstucki
Copy link
Contributor

Sorry for the delay answering, the desition to remove the snippets was in a limbo for a while.

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.

3 participants