Vetur: Customizable scaffold snippets

Created on 15 Mar 2019  路  17Comments  路  Source: vuejs/vetur

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.

feature-request

Most helpful comment

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.

All 17 comments

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

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

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

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.

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

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

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.

@khoanguyen96 has funded $20.00 to this issue.


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.

scaffold-snippet

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

  • :moneybag: Total deposit: $160.00
  • :tada: Repository reward(0%): $0.00
  • :wrench: Service fee(10%): $16.00

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

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

@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

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

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

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

Was this page helpful?
0 / 5 - 0 ratings