From fc007e0e04f0dfd36efa98397c3ec19174209363 Mon Sep 17 00:00:00 2001 From: BuriXon-code Date: Sat, 27 Dec 2025 15:55:53 +0100 Subject: [PATCH 1/3] Added syntax support for .mcfunction files (Minecraft functions) --- runtime/syntax/mcfunction.yaml | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 runtime/syntax/mcfunction.yaml diff --git a/runtime/syntax/mcfunction.yaml b/runtime/syntax/mcfunction.yaml new file mode 100644 index 0000000000..679108c619 --- /dev/null +++ b/runtime/syntax/mcfunction.yaml @@ -0,0 +1,50 @@ +filetype: mcfunction + +detect: + filename: "\\.mcfunction$" + +rules: + - comment: "#.*$" + + # === JSON === + - string: "\"([^\"\\\\]|\\\\.)*\"" + - special: "\"(text|color|bold|italic|underlined|strikethrough|obfuscated|extra|translate|with|score|name|objective)\"\\s*:" + + # === ENTITY / SELECTORS === + - type: "@[pares]" + - special: "@[pares]\\[[^\\]]*\\]" + + # === NUMBERS / BOOL === + - number: "\\b-?[0-9]+\\b" + - constant: "\\b(true|false)\\b" + + # === AXES === + - special: "[~^]" + + # === IDENTIFIERS === + - identifier: "\\bminecraft:[a-z0-9_./]+\\b" + - identifier: "\\b[a-z0-9_]+:[a-z0-9_./]+\\b" + + # === EFFECTS === + - constant: "\\b(speed|slowness|haste|mining_fatigue|strength|instant_health|instant_damage|jump_boost|nausea|regeneration|resistance|fire_resistance|water_breathing|invisibility|blindness|night_vision|hunger|weakness|poison|wither|health_boost|absorption|saturation|glowing|levitation|luck|unluck|slow_falling|conduit_power|dolphins_grace|bad_omen|hero_of_the_village|darkness)\\b" + + # === DANGEROUS COMMANDS === + - error: "\\b(kill|tp|teleport|clear|effect clear|data merge|item replace|loot spawn)\\s+@([ae])\\b" + - error: "\\b(kill|tp|teleport|clear|effect clear)\\s+@([ae])\\[.*?\\]" + - error: "\\b(scoreboard players reset)\\s+@([ae])\\b" + - error: "\\b(execute)\\b.*\\b(run)\\b.*\\b(kill|tp|teleport|clear)\\s+@([ae])\\b" + + # === MAIN COMMANDS === + - statement: "\\b(effect|execute|item|scoreboard|data|tag|tp|teleport|give|say|tellraw|summon|kill|function|schedule|loot|damage|attribute|bossbar|title|particle|playsound|stopsound|fill|setblock|clone|clear)\\b" + + # === SUBCOMMANDS === + - preproc: "\\b(give|clear|run|if|unless|store|as|at|positioned|facing|align|anchored|rotated|matches|modify|merge|get|set|add|remove|append|prepend|insert|entity|block|storage)\\b" + + # === SCORE / CONDITIONS === + - special: "\\b(score|scores|range|limit|distance|dx|dy|dz|x|y|z|level|sort|type|name|team|tag)\\b" + + # === SLOTS === + - identifier: "\\b[a-z0-9_]+:(mainhand|offhand|head|chest|legs|feet)\\b" + + # === SYMBOLS === + - symbol: "[{}\\[\\](),=]" From 32779cb4bea558568642321057285a093bcc3e51 Mon Sep 17 00:00:00 2001 From: BuriXon-code Date: Mon, 18 May 2026 11:30:14 +0200 Subject: [PATCH 2/3] Improved mcfunction syntax highlighting as suggested by Jenny (@Jenny-hso). --- runtime/syntax/mcfunction.yaml | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/runtime/syntax/mcfunction.yaml b/runtime/syntax/mcfunction.yaml index 679108c619..8c8c30caa5 100644 --- a/runtime/syntax/mcfunction.yaml +++ b/runtime/syntax/mcfunction.yaml @@ -4,20 +4,22 @@ detect: filename: "\\.mcfunction$" rules: - - comment: "#.*$" + # === COMMENTS === + - comment: + start: "(^|\\s)#" + end: "$" + rules: [] - # === JSON === - - string: "\"([^\"\\\\]|\\\\.)*\"" + # === DANGEROUS COMMANDS === + - error: "^\\s*(kill|tp|teleport)\\s+@([ae])(\\s|$).*$" + + # === JSON KEYS === - special: "\"(text|color|bold|italic|underlined|strikethrough|obfuscated|extra|translate|with|score|name|objective)\"\\s*:" # === ENTITY / SELECTORS === - type: "@[pares]" - special: "@[pares]\\[[^\\]]*\\]" - # === NUMBERS / BOOL === - - number: "\\b-?[0-9]+\\b" - - constant: "\\b(true|false)\\b" - # === AXES === - special: "[~^]" @@ -28,12 +30,6 @@ rules: # === EFFECTS === - constant: "\\b(speed|slowness|haste|mining_fatigue|strength|instant_health|instant_damage|jump_boost|nausea|regeneration|resistance|fire_resistance|water_breathing|invisibility|blindness|night_vision|hunger|weakness|poison|wither|health_boost|absorption|saturation|glowing|levitation|luck|unluck|slow_falling|conduit_power|dolphins_grace|bad_omen|hero_of_the_village|darkness)\\b" - # === DANGEROUS COMMANDS === - - error: "\\b(kill|tp|teleport|clear|effect clear|data merge|item replace|loot spawn)\\s+@([ae])\\b" - - error: "\\b(kill|tp|teleport|clear|effect clear)\\s+@([ae])\\[.*?\\]" - - error: "\\b(scoreboard players reset)\\s+@([ae])\\b" - - error: "\\b(execute)\\b.*\\b(run)\\b.*\\b(kill|tp|teleport|clear)\\s+@([ae])\\b" - # === MAIN COMMANDS === - statement: "\\b(effect|execute|item|scoreboard|data|tag|tp|teleport|give|say|tellraw|summon|kill|function|schedule|loot|damage|attribute|bossbar|title|particle|playsound|stopsound|fill|setblock|clone|clear)\\b" @@ -48,3 +44,12 @@ rules: # === SYMBOLS === - symbol: "[{}\\[\\](),=]" + + + # === DANGEROUS COMMANDS === + - error: "^\\s*(kill|tp|teleport)\\s+@([ae])(\\s|$).*$" + + # === CONSTANTS === + - constant.numeric: "\\b-?[0-9]+(?:\\.[0-9]+)?\\b" + - constant.bool: "\\b(true|false)\\b" + - constant.string: "\"([^\"\\\\]|\\\\.)*\"" From deabf5aa408108215610b4bfaba0cc9d5b44bcbc Mon Sep 17 00:00:00 2001 From: BuriXon-code Date: Mon, 18 May 2026 12:55:15 +0200 Subject: [PATCH 3/3] Improved mcfunction syntax highlighting as suggested by Jenny (@Jenny-hso). --- runtime/syntax/mcfunction.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/runtime/syntax/mcfunction.yaml b/runtime/syntax/mcfunction.yaml index 8c8c30caa5..fc6689bce8 100644 --- a/runtime/syntax/mcfunction.yaml +++ b/runtime/syntax/mcfunction.yaml @@ -10,9 +10,6 @@ rules: end: "$" rules: [] - # === DANGEROUS COMMANDS === - - error: "^\\s*(kill|tp|teleport)\\s+@([ae])(\\s|$).*$" - # === JSON KEYS === - special: "\"(text|color|bold|italic|underlined|strikethrough|obfuscated|extra|translate|with|score|name|objective)\"\\s*:" @@ -50,6 +47,6 @@ rules: - error: "^\\s*(kill|tp|teleport)\\s+@([ae])(\\s|$).*$" # === CONSTANTS === - - constant.numeric: "\\b-?[0-9]+(?:\\.[0-9]+)?\\b" + - constant.number: "\\b-?[0-9]+(?:\\.[0-9]+)?\\b" - constant.bool: "\\b(true|false)\\b" - constant.string: "\"([^\"\\\\]|\\\\.)*\""