Add snippets as a language (#185017)
* Add snippets as a language * Snippets -> Code Snippets * Add tests * json.snippets -> json.comments.snippets
This commit is contained in:
Родитель
34442b8b39
Коммит
5f9fc780c2
|
@ -41,8 +41,7 @@
|
|||
".code-workspace",
|
||||
"language-configuration.json",
|
||||
"icon-theme.json",
|
||||
"color-theme.json",
|
||||
".code-snippets"
|
||||
"color-theme.json"
|
||||
],
|
||||
"filenames": [
|
||||
"settings.json",
|
||||
|
@ -54,10 +53,6 @@
|
|||
"profiles.json",
|
||||
"devcontainer.json",
|
||||
".devcontainer.json"
|
||||
],
|
||||
"filenamePatterns": [
|
||||
"**/User/snippets/*.json",
|
||||
"**/User/profiles/*/snippets/*.json"
|
||||
]
|
||||
}, {
|
||||
"id": "json",
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
|
||||
var updateGrammar = require('vscode-grammar-updater');
|
||||
|
||||
function adaptJSON(grammar, name, replacementScope) {
|
||||
function adaptJSON(grammar, name, replacementScope, replaceeScope = 'json') {
|
||||
grammar.name = name;
|
||||
grammar.scopeName = `source${replacementScope}`;
|
||||
|
||||
const regex = new RegExp(`\.${replaceeScope}`, 'g');
|
||||
var fixScopeNames = function (rule) {
|
||||
if (typeof rule.name === 'string') {
|
||||
rule.name = rule.name.replace(/\.json/g, replacementScope);
|
||||
rule.name = rule.name.replace(regex, replacementScope);
|
||||
}
|
||||
if (typeof rule.contentName === 'string') {
|
||||
rule.contentName = rule.contentName.replace(/\.json/g, replacementScope);
|
||||
rule.contentName = rule.contentName.replace(regex, replacementScope);
|
||||
}
|
||||
for (var property in rule) {
|
||||
var value = rule[property];
|
||||
|
@ -35,3 +35,5 @@ var tsGrammarRepo = 'microsoft/vscode-JSON.tmLanguage';
|
|||
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSON.tmLanguage.json');
|
||||
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSONC.tmLanguage.json', grammar => adaptJSON(grammar, 'JSON with Comments', '.json.comments'));
|
||||
updateGrammar.update(tsGrammarRepo, 'JSON.tmLanguage', './syntaxes/JSONL.tmLanguage.json', grammar => adaptJSON(grammar, 'JSON Lines', '.json.lines'));
|
||||
|
||||
updateGrammar.update('jeff-hykin/better-snippet-syntax', 'autogenerated/jsonc.tmLanguage.json', './syntaxes/snippets.tmLanguage.json', grammar => adaptJSON(grammar, 'Snippets', '.json.comments.snippets', 'json.comments'));
|
||||
|
|
|
@ -11,6 +11,18 @@
|
|||
},
|
||||
"license": "MIT",
|
||||
"version": "0.0.0"
|
||||
},
|
||||
{
|
||||
"component": {
|
||||
"type": "git",
|
||||
"git": {
|
||||
"name": "jeff-hykin/better-snippet-syntax",
|
||||
"repositoryUrl": "https://github.com/jeff-hykin/better-snippet-syntax",
|
||||
"commitHash": "2b1bb124cb2b9c75c3c80eae1b8f3a043841d654"
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"version": "1.0.2"
|
||||
}
|
||||
],
|
||||
"version": 1
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
".jslintrc",
|
||||
".jsonld",
|
||||
".geojson",
|
||||
".ipynb",
|
||||
".ipynb",
|
||||
".vuerc"
|
||||
],
|
||||
"filenames": [
|
||||
|
@ -77,6 +77,20 @@
|
|||
],
|
||||
"filenames": [],
|
||||
"configuration": "./language-configuration.json"
|
||||
},
|
||||
{
|
||||
"id": "snippets",
|
||||
"aliases": [
|
||||
"Code Snippets"
|
||||
],
|
||||
"extensions": [
|
||||
".code-snippets"
|
||||
],
|
||||
"filenamePatterns": [
|
||||
"**/User/snippets/*.json",
|
||||
"**/User/profiles/*/snippets/*.json"
|
||||
],
|
||||
"configuration": "./language-configuration.json"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
|
@ -94,6 +108,11 @@
|
|||
"language": "jsonl",
|
||||
"scopeName": "source.json.lines",
|
||||
"path": "./syntaxes/JSONL.tmLanguage.json"
|
||||
},
|
||||
{
|
||||
"language": "snippets",
|
||||
"scopeName": "source.json.comments.snippets",
|
||||
"path": "./syntaxes/snippets.tmLanguage.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
// Each snippet is defined under a snippet name and has a scope, prefix, body and
|
||||
// description. The scope defines in watch languages the snippet is applicable. The prefix is what is
|
||||
// used to trigger the snippet and the body will be expanded and inserted.Possible variables are:
|
||||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
||||
// Placeholders with the same ids are connected.
|
||||
// Example:
|
||||
"MSFT Copyright Header": {
|
||||
"scope": "javascript,typescript,css",
|
||||
"prefix": [
|
||||
"header",
|
||||
"stub",
|
||||
"copyright"
|
||||
],
|
||||
"body": [
|
||||
"/*---------------------------------------------------------------------------------------------",
|
||||
" * Copyright (c) Microsoft Corporation. All rights reserved.",
|
||||
" * Licensed under the MIT License. See License.txt in the project root for license information.",
|
||||
" *--------------------------------------------------------------------------------------------*/",
|
||||
"",
|
||||
"$0"
|
||||
],
|
||||
"description": "Insert Copyright Statement"
|
||||
},
|
||||
"TS -> Inject Service": {
|
||||
"scope": "typescript",
|
||||
"description": "Constructor Injection Pattern",
|
||||
"prefix": "@inject",
|
||||
"body": "@$1 private readonly _$2: ${1},$0"
|
||||
},
|
||||
"TS -> Event & Emitter": {
|
||||
"scope": "typescript",
|
||||
"prefix": "emitter",
|
||||
"description": "Add emitter and event properties",
|
||||
"body": [
|
||||
"private readonly _onDid$1 = new Emitter<$2>();",
|
||||
"readonly onDid$1: Event<$2> = this._onDid$1.event;"
|
||||
],
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче