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

Customizable scaffold snippets #1151

Closed
octref opened this issue Mar 14, 2019 · 18 comments
Closed

Customizable scaffold snippets #1151

octref opened this issue Mar 14, 2019 · 18 comments

Comments

@octref
Copy link
Member

octref commented Mar 14, 2019

#903 is not a good solution. As time goes on we'll have more and more snippet coming in, and we can't just include them all. We should provide a way to let users customize their scaffold snippets.

@coyotte508
Copy link

It would be cool to be able to customize "script wtih typescript" snippet to use something like vue-property-decorator.

@marius815
Copy link

I completely agree with being able to customize your own scaffold snippets, as I feel even the above PR is lacking my features.

@sandalwoodsh
Copy link

Agreed. Allowing users the ability to customize their snippets would be awesome.

@jko206
Copy link

jko206 commented Jun 24, 2019

I am all for the customizable scaffolding.

At my office, we use the following:

<template>
</template>
<script>
</script>
<style lang="scss" scoped>
@import 'global.scss`;
</style>

I'd like to be able to do this automatically every time I make a new .vue file.

@coyotte508
Copy link

Would be nice if there was a way to donate money to specific issues :)

@octref
Copy link
Member Author

octref commented Jun 28, 2019

This is on the top of my todo list, but just sayin', I wouldn't mind a cup of coffee 😉
https://issuehunt.io/r/vuejs/vetur/issues/1151

@octref octref added this to the On Deck milestone Jun 29, 2019
@octref
Copy link
Member Author

octref commented Jun 29, 2019

Here's the rough plan:

  • (User level config) Create a folder under snippets of VS Code's user data dir:
    • Windows: %APPDATA%\Code\User\snippets\vetur
    • macOS: $HOME/Library/Application Support/Code/User/snippets/vetur
    • Linux: $HOME/.config/Code/User/snippets/vetur
  • (Project level config) Create a folder under .vscode in the project root, .vscode/vetur/snippets/.
  • Project level snippets always show up before user level snippets.
  • Allow .vue components in the snippets folder. For example, snippets/foo.vue should show a completion item Scaffold with foo.vue.
  • You can have top-level folders named after block names and custom blocks. For example, snippets/style/my-style.vue should show a completion style with my-style.
  • You can use Textmate snippet syntax in the .vue files.

@IssueHuntBot
Copy link

@khoaNguyen96 has funded $20.00 to this issue.


@WORMSS
Copy link

WORMSS commented Aug 6, 2019

I wholey support (Project level config) Create a folder under .vscode in the project root, .vscode/vetur/snippets/
that way the entire team can benefit from it just being located in the .git folder.. 👍 👍

I will see if I can get my work to send a little support.

@octref octref closed this as completed in 7589443 Aug 9, 2019
@octref
Copy link
Member Author

octref commented Aug 9, 2019

scaffold-snippet

@IssueHuntBot
Copy link

@octref has rewarded $144.00 to @octref. See it on IssueHunt

  • 💰 Total deposit: $160.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $16.00

@coyotte508
Copy link

Awesome. I updated VSCode just to get the new version and it works great!

@oliverw
Copy link

oliverw commented Oct 18, 2020

@octref Is that vue-class-component.vue shown in your GIF available somewhere?

@yoyo930021
Copy link
Member

@octref Is that vue-class-component.vue shown in your GIF available somewhere?

The GIF is only shown customizable scaffold snippets feature.
You can use this feature for impl your custom vue-class-component.vue snippets.
https://vuejs.github.io/vetur/snippet.html#customizable-scaffold-snippets

@oliverw
Copy link

oliverw commented Oct 18, 2020

@yoyo930021 Thanks. I was hoping to avoid inventing my own when @octref already did exactly what I need 😄

@yoyo930021
Copy link
Member

@yoyo930021 Thanks. I was hoping to avoid inventing my own when @octref already did exactly what I need 😄

It's just a demo.
It's not built into vetur.

@oliverw
Copy link

oliverw commented Oct 18, 2020

@octref I know. Still, would be useful to have it available for reference.

@bogdankorshunov
Copy link

@octref Is it possible to use custom attributes for vetur? I would like to use my snippet like "for" which will output:

v-for="${1} in ${2}'" :key="${1}"
v-for="item in items" :key="item"

Here is a hint of the standard directive
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants