From 5d9bb730c8858f961c81f2ad4ad304863ce5345c Mon Sep 17 00:00:00 2001 From: Death-123 <50763371+Death-123@users.noreply.github.com> Date: Sun, 5 Apr 2020 23:19:37 +0800 Subject: [PATCH] feat: more code highlight and snippets (#16) Mentioned in #11 --- language/snippets/aether_legacy.json | 30 +++ language/snippets/global.json | 13 +- language/snippets/jei.json | 51 +++++ language/snippets/zenscript.json | 204 ++++++++++++++++++++ language/syntaxes/zenscript.tmLanguage.json | 139 ++++++++++--- 5 files changed, 409 insertions(+), 28 deletions(-) create mode 100644 language/snippets/aether_legacy.json create mode 100644 language/snippets/jei.json create mode 100644 language/snippets/zenscript.json diff --git a/language/snippets/aether_legacy.json b/language/snippets/aether_legacy.json new file mode 100644 index 0000000..066da03 --- /dev/null +++ b/language/snippets/aether_legacy.json @@ -0,0 +1,30 @@ +{ + "ImportAether":{ + "prefix": "AetherImport", + "body":[ + "import mods.aether_legacy;" + ], + "description": "Import Aether" + }, + "registerEnchantement": { + "prefix": "registerEnchantement", + "body":[ + "Enchanter.registerEnchantment(input, output, time);" + ], + "description": "Out put messages" + }, + "registerAccessory": { + "prefix": "registerAccessory", + "body":[ + "Acessory.registerAccessory(input, accessory);" + ], + "description": "Out put messages" + }, + "registerFreezable": { + "prefix": "registerAccessory", + "body":[ + "registerFreezable(input, output, timeRequired);" + ], + "description": "Out put messages" + } +} \ No newline at end of file diff --git a/language/snippets/global.json b/language/snippets/global.json index c31ecdb..f89571f 100644 --- a/language/snippets/global.json +++ b/language/snippets/global.json @@ -1,9 +1,18 @@ { - "Print": { + "Print":{ "prefix": "print", - "body": ["print(\"$1\");"], + "body":[ + "print(${type:String});" + ], "description": "Prints the string to the crafttweaker log as information." }, + "Import":{ + "prefix": "import", + "body":[ + "import ${type:module};" + ], + "description": "Import a mod" + }, "Total_Actions": { "prefix": "tota", "body": ["totalActions();"], diff --git a/language/snippets/jei.json b/language/snippets/jei.json new file mode 100644 index 0000000..6c0f50a --- /dev/null +++ b/language/snippets/jei.json @@ -0,0 +1,51 @@ +{ + "ImportJei":{ + "prefix": "jeiImport", + "body":[ + "import mods.jei.JEI;" + ], + "description": "Import Jei" + }, + "JeiHide":{ + "prefix": "jeiRemoveAndHide", + "body":[ + "mods.jei.JEI.hide(${item});" + ], + "description": "Hide item from JEI" + }, + "JeiRemoveAndHide":{ + "prefix": "jeiRemoveAndHide", + "body":[ + "mods.jei.JEI.removeAndHide(${item});" + ], + "description": "remove a item recipe and hide it in JEI" + }, + "JeiRemoveAndHideNbtMatch":{ + "prefix": "jeiRemoveAndHideNbtMatch", + "body":[ + "mods.jei.JEI.removeAndHide(${item}, false);" + ], + "description": "remove a item recipe and hide it in JEI" + }, + "JeiHideCategory":{ + "prefix": "jeiHideCategory", + "body":[ + "mods.jei.JEI.hideCategory(\"${category}\");" + ], + "description": "Hide a Category" + }, + "JeiAddItem":{ + "prefix": "jeiAddItem", + "body": [ + "mods.jei.JEI.addItem(${item})" + ], + "description": "Add a item to Jei" + }, + "JeiAddDesciption":{ + "prefix": "jeiAddDesciption", + "body": [ + "mods.jei.JEI.addDescription(${item},\"${description}\");" + ], + "description": "Add a description to a item in jei" + } +} \ No newline at end of file diff --git a/language/snippets/zenscript.json b/language/snippets/zenscript.json new file mode 100644 index 0000000..4cfe25d --- /dev/null +++ b/language/snippets/zenscript.json @@ -0,0 +1,204 @@ +{ + "For":{ + "prefix": "for", + "body":[ + "for ${1:num},${2:item} in ${3:array} {", + "\t", + "}" + ], + "description": "For element" + }, + "If":{ + "prefix": "if", + "body":[ + "if (${cond}) {", + "\t${branch1}", + "} else {", + "\t${branch2}", + "}" + ], + "description": "If element else element" + }, + "Val":{ + "prefix": "val", + "body":[ + "val ${name} = ${expression};" + ], + "description": "Create a variable" + }, + "Var":{ + "prefix": "var", + "body":[ + "var ${name} = ${expression};" + ], + "description": "Create a variable" + }, + "Recipes":{ + "prefix": "recipes", + "body":[ + "recipes" + ], + "description": "Recipes Manager" + }, + "Furnace":{ + "prefix": "Furnace", + "body":[ + "furnace" + ], + "description": "Furnace Manager" + }, + "AddShaped":{ + "prefix":"recipeAddshaped", + "body":[ + "recipes.addShaped(${output}, ${input});" + ], + "description": "Add Shaped Craft" + }, + "AddShapeless":{ + "prefix":"recipeAddshapeless", + "body":[ + "recipes.addShapeless(${output}, ${input});" + ], + "description": "Add Shapeless Craft" + }, + "RemoveCraft":{ + "prefix":"remove", + "body":[ + "recipes.addShaped(${output});" + ], + "description": "Remove Craft" + }, + "RemoveShaped":{ + "prefix":"removeshaped", + "body":[ + "recipes.removeShaped(${output}, ${input});" + ], + "description": "Remove Shaped Craft" + }, + "RemoveShapeless":{ + "prefix":"removeshapeless", + "body":[ + "recipes.removeShapeless(${output});" + ], + "description": "Remove Shapedless Craft" + }, + "AddOreDictionary":{ + "prefix":"add", + "body":[ + "${od}.add(${item});" + ], + "description": "Add item to OD." + }, + "RemoveOreDictionary":{ + "prefix":"remove", + "body":[ + "${od}.remove(${item});" + ], + "description": "Remove item from OD." + }, + "MirrorOreDictionary":{ + "prefix":"mirror", + "body":[ + "${od1}.mirror(${od2});" + ], + "description": "Mirror OD. to OD." + }, + "AddAllOreDictionary":{ + "prefix":"addall", + "body":[ + "${od1}.addAll(${od2});" + ], + "description": "Add OD. to OD." + }, + "AddFurnaceRecipe":{ + "prefix":"addrecipe", + "body":[ + "furnace.addRecipe(${output}, ${input}, ${xp});" + ], + "description": "Add Furnace Recipe" + }, + "RemoveFurnaceRecipe":{ + "prefix":"remove", + "body":[ + "furnace.remove(${output}, ${input});" + ], + "description": "Remove Furnace Recipe" + }, + "SetFuel":{ + "prefix":"setfuel", + "body":[ + "furnace.setFuel(${item}, ${value]});" + ], + "description": "Set Furnace Fuel" + }, + "WithTag":{ + "prefix":"withtag", + "body":[ + "${item}.withTag(${tag});" + ], + "description": "Items with tag" + }, + "WithDamage":{ + "prefix":"withdamage", + "body":[ + "${item}.withDamage(${value});" + ], + "description": "Item with damage" + }, + "OnlyWithTag":{ + "prefix":"onlywithtag", + "body":[ + "${item}.onlyWithTag(${value});" + ], + "description":"Item with tag only" + }, + "OnlyDamageAtLeast":{ + "prefix":"onlydamageatleast", + "body":[ + "${item}.onlyDamageAtLeast(${value});" + ], + "description": "Least with damage" + }, + "OnlyDamageAtMost":{ + "prefix":"onlydamageatMost", + "body":[ + "${item}.onlyDamageAtMost(${value});" + ], + "description": "Most with damage" + }, + "OnlyDamageBetween":{ + "prefix":"onlydamagebetween", + "body":[ + "${item}.onlyDamageBetween(${value1}, ${value2});" + ], + "description": "Damage between with two num" + }, + "Reuse":{ + "prefix":"reuse", + "body":[ + "${item}.reuse(${item});" + ], + "description": "Retrun item" + }, + "TransFormDamage":{ + "prefix":"transformdamage", + "body":[ + "${item}.transformDamage(${value});" + ], + "description": "Make item add damage" + }, + "DisPlayName":{ + "prefix":"displayname", + "body":[ + "${item}.displayName = \"${value}\";" + ], + "description": "Set item display name" + }, + "Null":{ + "prefix":"null", + "body":[ + "null" + ], + "description": "Empty Value" + } +} \ No newline at end of file diff --git a/language/syntaxes/zenscript.tmLanguage.json b/language/syntaxes/zenscript.tmLanguage.json index 0f117f2..10f3de5 100644 --- a/language/syntaxes/zenscript.tmLanguage.json +++ b/language/syntaxes/zenscript.tmLanguage.json @@ -3,14 +3,87 @@ "scopeName": "source.zenscript", "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "patterns": [ + { "include": "#import" }, + { "include": "#functions" }, + { "include": "#function-call" }, + { "include": "#dots" }, + { "include": "#var" }, + { "include": "#preprocessors" }, { "include": "#brackethandlers" }, - { "include": "#preprocessor" }, { "include": "#comments" }, { "include": "#string" }, { "include": "#values" }, - { "include": "#keywords" } + { "include": "#keywords" }, + { "include": "#constants" }, + { "include": "#operators" } ], "repository": { + "import": { + "comment": "package import", + "name": "meta.import.zenscript", + "begin": "\\b(import)\\b\\s*", + "beginCaptures": { + "1": { + "name": "keyword.other.import.zenscript" + } + }, + "end": "\\s*(;)", + "endCaptures": { + "1": { + "name": "punctuation.terminator.zenscript" + } + } + }, + "functions": { + "comment": "functions", + "name": "meta.function.zenscript", + "match": "(?<=function\\s)([A-Za-z_$][\\w$]*)\\s*(?=\\()", + "captures": { + "1": { + "name": "entity.name.function.zenscript" + } + } + }, + "function-call": { + "comment": "function calls", + "name": "meta.function-call.zenscript", + "match": "(? ]+:)", @@ -22,15 +95,6 @@ } ] }, - "preprocessor": { - "patterns": [ - { - "name": "meta.preprocessor.zenscript", - "begin": "#(?=debug|ignoreBracketErrors|loader|modloaded|norun|priority|ikwid|sideonly|disable_search_tree|profile)", - "end": "$\\n?" - } - ] - }, "comments": { "patterns": [ { @@ -83,32 +147,45 @@ "patterns": [ { "name": "constant.numeric.integer.zenscript", - "match": "(?:0x[A-Fa-f0-9]*)|(?:-?(0|[1-9][0-9]*))" + "match": "\\b(?=|>|==|=|!=|!|\\$)" } ] - } + }, + "constants": { + "comment": "constants (true, false, null)", + "name": "constant.language.zenscript", + "match": "\\b(true|false|null)\\b" + }, + "operators": { + "patterns": [ + { + "comment": "math operators", + "name": "keyword.operator", + "match": "(\\.\\.|\\+=|\\+|-=|-|\\*=|\\*|\\/=|\\/|%=|%|\\|=|\\||\\|\\||&=|&&|&|\\^=|\\^|\\?|:|~=|~|;|<=|<|>=|>|==|=|!=|!|\\$)" + } + ] + } } }