项目作者: cipchk

项目描述 :
Generate a snippet extensions for vscode.
高级语言: TypeScript
项目地址: git://github.com/cipchk/vscode-snippet-generator.git
创建时间: 2018-12-08T16:23:40Z
项目社区:https://github.com/cipchk/vscode-snippet-generator

开源协议:MIT License

下载


vscode-snippet-generator

CI
Dependency Status
NPM version

Generate a snippet extensions for vscode.

Usage VSCode extension

  1. Install Dynamic Custom Snippets extension.
  2. Add snippet files into .vscode/snippets/ folder. (Please refer to the template content Snippet tempalte)
  3. The first time create the .vscode/snippets/ folder, need to restart vscode; otherwise you only need to trigger the vscode-snippet-generator: Cache all dynamic snippets command again.

Happy coding!!!

You can configure "vscode-snippet-generator.prefix": "" in settings.json to change the prefix.

You can configuae "vscode-snippet-generator.languages": ["html", "typescript"] in settings.json to support language list.

Usage Command Line: Quick start

  1. $ git clone --depth 1 https://github.com/cipchk/vscode-snippet-generator-tpl.git
  2. $ cd vscode-snippet-generator-tpl
  3. $ # build
  4. $ npm run build
  5. $ # package vscode extension
  6. $ npm run release

Cli Options

  1. vscode-snippet-generator --help

Snippet tempalte

Markdown file symbol of a specify snippet, like this:

  1. ---
  2. prefix: button
  3. description: 按钮
  4. scope: typescript,html
  5. ---
  6. ```html
  7. <button${1: type="${2|text,tel|}"}>
  8. $0
  9. <button>
  1. - `prefix` defines how this snippet is selected from IntelliSense and tab completion. In this case `button`.
  2. - `description` is the description used in the IntelliSense drop down.
  3. - `scope` Restrict template scope, if not specified, it means no restriction. In this case `typescript` and `html` document.
  4. - markdown body is defines snippet code, muse be hava a code tag.
  5. > How to writing snippet code, pls refre to [vscode-Creating your own snippets](https://code.visualstudio.com/docs/editor/userdefinedsnippets)
  6. ## I18n
  7. The `description` support i18n, like this:
  8. ```markdown
  9. ---
  10. prefix: button
  11. description:
  12. zh-CN: 按钮
  13. en-US: Button
  14. ---

Specify language version to generate with i18n parameter.

  1. vscode-snippet-generator --i18n=zh-CN --outFile=snippets-zh-CN.json
  2. vscode-snippet-generator --i18n=en-US --outFile=snippets-en-US.json

If you want to display multiple languages in a snippet extension, you can use i18nTpl.

  1. # window
  2. vscode-snippet-generator --i18nTpl=\"{zh-CN}({en-US})\"

License

The MIT License (see the LICENSE file for the full text)