{ "fileTypes": [ "gd" ], "scopeName": "source.gdscript", "name": "GDScript", "patterns": [ { "include": "#nodepath_object" }, { "include": "#nodepath_function" }, { "include": "#base_expression" }, { "include": "#logic_op" }, { "include": "#compare_op" }, { "include": "#arithmetic_op" }, { "include": "#assignment_op" }, { "include": "#control_flow" }, { "include": "#decorators" }, { "include": "#keywords" }, { "include": "#self" }, { "include": "#const_def" }, { "include": "#class_def" }, { "include": "#var_def" }, { "include": "#type_hint" }, { "include": "#class_name" }, { "include": "#builtin_func" }, { "include": "#node_path" }, { "include": "#builtin_get_node_shorthand" }, { "include": "#builtin_classes" }, { "include": "#const_vars" }, { "include": "#pascal_case_class" }, { "include": "#class_new" }, { "include": "#class_is" }, { "include": "#class_enum" }, { "include": "#signal-declaration-bare" }, { "include": "#signal-declaration" }, { "include": "#function-declaration" }, { "include": "#any-method" }, { "include": "#any-property" }, { "include": "#extends" } ], "repository": { "comment": { "captures": { "1": { "name": "punctuation.definition.comment.number-sign.gdscript" } }, "match": "(#).*$\\n?", "name": "comment.line.number-sign.gdscript" }, "strings": { "patterns": [ { "begin": "(?:(?<=get_node|has_node|find_node|get_node_or_null|NodePath)\\s*\\(\\s*)", "end": "(?:\\s*\\))", "patterns": [ { "begin": "[\\\"\\']", "end": "[\\\"\\']", "name": "constant.character.escape" }, { "include": "#base_expression" } ] }, { "name": "invalid.illegal.escape.gdscript", "begin": "'''", "end": "'''" }, { "begin": "\"", "end": "\"", "patterns": [ { "name": "constant.character.escape.untitled", "match": "\\\\." } ], "name": "string.quoted.double.gdscript" }, { "begin": "'", "end": "'", "patterns": [ { "name": "constant.character.escape.untitled", "match": "\\\\." } ], "name": "string.quoted.single.gdscript" }, { "begin": "@\"", "end": "\"", "patterns": [ { "name": "constant.character.escape.untitled", "match": "\\." } ], "name": "string.nodepath.gdscript" } ] }, "nodepath_object": { "name": "meta.literal.nodepath.gdscript", "begin": "(NodePath)\\s*(?:\\()", "beginCaptures": { "1": { "name": "support.class.library.gdscript" } }, "end": "(?:\\))", "patterns": [ { "begin": "[\\\"\\']", "end": "[\\\"\\']", "name": "constant.character.escape" } ] }, "nodepath_function": { "name": "meta.literal.nodepath.gdscript", "begin": "(get_node_or_null|has_node|find_node|get_node)\\s*(?:\\()", "beginCaptures": { "1": { "name": "entity.name.function.gdscript" } }, "end": "(?:\\))", "patterns": [ { "begin": "[\\\"\\']", "end": "[\\\"\\']", "name": "constant.character.escape" } ] }, "self": { "match": "\\bself\\b", "name": "variable.language.gdscript" }, "base_expression": { "patterns": [ { "include": "#builtin_get_node_shorthand" }, { "include": "#nodepath_object" }, { "include": "#nodepath_function" }, { "include": "#strings" }, { "include": "#keywords" }, { "include": "#logic_op" }, { "include": "#control_flow" }, { "include": "#function-call" }, { "include": "#comment" }, { "include": "#self" }, { "include": "#letter" }, { "include": "#numbers" }, { "include": "#builtin_func" }, { "include": "#builtin_classes" }, { "include": "#const_vars" }, { "include": "#pascal_case_class" }, { "include": "#line-continuation" } ] }, "logic_op": { "match": "\\b(and|or|not)\\b", "name": "keyword.operator.wordlike.gdscript" }, "compare_op": { "match": "<=|>=|==|<|>|!=", "name": "keyword.operator.comparison.gdscript" }, "arithmetic_op": { "match": "\\+=|-=|\\*=|/=|%=|&=|\\|=|\\*|/|%|\\+|-|<<|>>|&|\\||\\^|~", "name": "keyword.operator.arithmetic.gdscript" }, "assignment_op": { "match": "=", "name": "keyword.operator.assignment.gdscript" }, "control_flow": { "match": "\\b(?i:if|elif|else|for|while|break|continue|pass|return|match|in|yield)\\b", "name": "keyword.control.gdscript" }, "keywords": { "match": "\\b(?i:class|class_name|extends|is|onready|tool|static|export|setget|const|as|void|enum|preload|assert|breakpoint|rpc|sync|remote|master|puppet|slave|remotesync|mastersync|puppetsync)\\b", "name": "keyword.language.gdscript" }, "letter": { "match": "\\b(?i:true|false|null)\\b", "name": "constant.language.gdscript" }, "numbers": { "patterns": [ { "match": "\\b(?i:0x\\h*)\\b", "name": "constant.numeric.integer.hexadecimal.gdscript" }, { "match": "\\b(?i:(\\d+\\.\\d*(e[\\-\\+]?\\d+)?))\\b", "name": "constant.numeric.float.gdscript" }, { "match": "\\b(?i:(\\.\\d+(e[\\-\\+]?\\d+)?))\\b", "name": "constant.numeric.float.gdscript" }, { "match": "\\b(?i:(\\d+e[\\-\\+]?\\d+))\\b", "name": "constant.numeric.float.gdscript" }, { "match": "\\b\\d+\\b", "name": "constant.numeric.integer.gdscript" } ] }, "const_def": { "match": "\\b(?i:(const))\\s+([a-zA-Z_][a-zA-Z_0-9]*)", "captures": { "1": { "name": "storage.type.const.gdscript" }, "2": { "name": "constant.language.gdscript" } } }, "var_def": { "match": "\\b(?i:(var))\\s+(?=[a-zA-Z_][a-zA-Z_0-9]*)", "captures": { "1": { "name": "storage.type.var.gdscript" } } }, "type_hint": { "match": "\\:\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*(?=[=\\n]|setget)", "captures": { "1": { "name": "entity.name.type.class.gdscript" } } }, "class_def": { "captures": { "1": { "name": "entity.name.type.class.gdscript" }, "2": { "name": "class.other.gdscript" } }, "match": "(?<=^class)\\s+([a-zA-Z_]\\w*)\\s*(?=:)" }, "class_new": { "captures": { "1": { "name": "entity.name.type.class.gdscript" }, "2": { "name": "storage.type.new.gdscript" } }, "match": "\\b([a-zA-Z_][a-zA-Z_0-9]*).(new)\\(" }, "class_is": { "captures": { "1": { "name": "storage.type.is.gdscript" }, "2": { "name": "entity.name.type.class.gdscript" } }, "match": "\\s+(is)\\s+([a-zA-Z_][a-zA-Z_0-9]*)" }, "class_enum": { "captures": { "1": { "name": "entity.name.type.class.gdscript" }, "2": { "name": "constant.language.gdscript" } }, "match": "\\b([A-Z][a-zA-Z_0-9]*)\\.([A-Z_0-9]+)" }, "class_name": { "captures": { "1": { "name": "entity.name.type.class.gdscript" }, "2": { "name": "class.other.gdscript" } }, "match": "(?<=class_name)\\s+([a-zA-Z_][a-zA-Z_0-9]*(\\.([a-zA-Z_][a-zA-Z_0-9]*))?)" }, "extends": { "match": "(?<=extends)\\s+[a-zA-Z_][a-zA-Z_0-9]*(\\.([a-zA-Z_][a-zA-Z_0-9]*))?", "name": "entity.other.inherited-class.gdscript" }, "builtin_func": { "match": "(?)\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*\\:", "captures": { "1": {}, "2": { "name": "entity.name.type.class.gdscript" } } } ] }, "function-declaration": { "name": "meta.function.gdscript", "begin": "(?x) \\s*\n (func) \\s+\n ([a-zA-Z_][a-zA-Z_0-9]*) \\s*\n (?=\\()", "end": "(:|(?=[#'\"\\n]))", "beginCaptures": { "1": { "name": "storage.type.function.gdscript" }, "2": { "name": "entity.name.function.gdscript" } }, "patterns": [ { "include": "#parameters" }, { "include": "#line-continuation" }, { "match": "\\s*(\\-\\>)\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*\\:", "captures": { "1": {}, "2": { "name": "entity.name.type.class.gdscript" } } } ] }, "parameters": { "name": "meta.function.parameters.gdscript", "begin": "(\\()", "end": "(\\))", "beginCaptures": { "1": { "name": "punctuation.definition.parameters.begin.gdscript" } }, "endCaptures": { "1": { "name": "punctuation.definition.parameters.end.gdscript" } }, "patterns": [ { "include": "#annotated-parameter" }, { "match": "(?x)\n ([[:alpha:]_]\\w*)\n \\s* (?: (,) | (?=[)#\\n=]))\n", "captures": { "1": { "name": "variable.parameter.function.language.gdscript" }, "2": { "name": "punctuation.separator.parameters.gdscript" } } }, { "include": "#comment" }, { "include": "#loose-default" } ] }, "loose-default": { "begin": "(=)", "end": "(,)|(?=\\))", "beginCaptures": { "1": { "name": "keyword.operator.gdscript" } }, "endCaptures": { "1": { "name": "punctuation.separator.parameters.gdscript" } }, "patterns": [ { "include": "#base_expression" } ] }, "annotated-parameter": { "begin": "(?x)\n \\b\n ([[:alpha:]_]\\w*) \\s* (:)\n", "end": "(,)|(?=\\))", "beginCaptures": { "1": { "name": "variable.parameter.function.language.gdscript" }, "2": { "name": "punctuation.separator.annotation.gdscript" } }, "endCaptures": { "1": { "name": "punctuation.separator.parameters.gdscript" } }, "patterns": [ { "include": "#base_expression" }, { "name": "keyword.operator.assignment.gdscript", "match": "=(?!=)" } ] }, "annotated-parameter2": { "begin": "(?x)\n \\b\n ([[:alpha:]_]\\w*) \\s* (:) \\s* ([[:alpha:]_]\\w*)? \\s* (=)? \\s* ([[:alpha:].0-9\\'\\\"_]*)?\n", "end": "(,)|(?=\\))", "beginCaptures": { "1": { "name": "variable.parameter.function.language.gdscript" }, "2": { "name": "punctuation.separator.annotation.gdscript" }, "3": { "patterns": [ { "include": "#builtin_classes" }, { "include": "#pascal_case_class" } ] }, "4": { "name": "keyword.operator.assignment.gdscript" }, "5": { "patterns": [ { "include": "#base_expression" } ] } }, "endCaptures": { "1": { "name": "punctuation.separator.parameters.gdscript" } } }, "line-continuation": { "patterns": [ { "match": "(\\\\)\\s*(\\S.*$\\n?)", "captures": { "1": { "name": "punctuation.separator.continuation.line.gdscript" }, "2": { "name": "invalid.illegal.line.continuation.gdscript" } } }, { "begin": "(\\\\)\\s*$\\n?", "end": "(?x)\n (?=^\\s*$)\n |\n (?! (\\s* [rR]? (\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))\n |\n (\\G $) (?# '\\G' is necessary for ST)\n )\n", "beginCaptures": { "1": { "name": "punctuation.separator.continuation.line.gdscript" } }, "patterns": [ { "include": "#base_expression" } ] } ] }, "any-method": { "match": "\\b([A-Za-z_]\\w*)\\b(?=\\s*(?:[(]))", "name": "support.function.any-method.gdscript" }, "any-property": { "match": "(?<=[^.]\\.)\\b([A-Za-z_]\\w*)\\b(?![(])", "name": "variable.other.property.gdscript" }, "function-call": { "name": "meta.function-call.gdscript", "comment": "Regular function call of the type \"name(args)\"", "begin": "(?x)\n \\b(?=\n ([[:alpha:]_]\\w*) \\s* (\\()\n )\n", "end": "(\\))", "endCaptures": { "1": { "name": "punctuation.definition.arguments.end.gdscript" } }, "patterns": [ { "include": "#function-name" }, { "include": "#function-arguments" } ] }, "function-name": { "patterns": [ { "include": "#builtin_func" }, { "include": "#builtin_classes" }, { "comment": "Some color schemas support meta.function-call.generic scope", "name": "support.function.any-method.gdscript", "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n" } ] }, "function-arguments": { "begin": "(\\()", "end": "(?=\\))(?!\\)\\s*\\()", "beginCaptures": { "1": { "name": "punctuation.definition.arguments.begin.gdscript" } }, "contentName": "meta.function-call.arguments.gdscript", "patterns": [ { "name": "punctuation.separator.arguments.gdscript", "match": "(,)" }, { "match": "\\b([[:alpha:]_]\\w*)\\s*(=)(?!=)", "captures": { "1": { "name": "variable.parameter.function-call.gdscript" }, "2": { "name": "keyword.operator.assignment.gdscript" } } }, { "name": "keyword.operator.assignment.gdscript", "match": "=(?!=)" }, { "include": "#base_expression" }, { "match": "\\s*(\\))\\s*(\\()", "captures": { "1": { "name": "punctuation.definition.arguments.end.gdscript" }, "2": { "name": "punctuation.definition.arguments.begin.gdscript" } } } ] } } }