{
    "name": "slint",
    "scopeName": "source.slint",
    "foldingStartMarker": "\\{\\s*$",
    "foldingStopMarker": "^\\s*\\}",
    "patterns": [
        {
            "include": "#comment"
        },
        {
            "include": "#import-list"
        },
        {
            "include": "#export-list"
        },
        {
            "include": "#struct"
        },
        {
            "include": "#enum"
        },
        {
            "include": "#global"
        },
        {
            "include": "#component"
        },
        {
            "match": "(?<!-)\\bexport\\b(?!-)",
            "name": "keyword.other.export.slint"
        },
        {
            "comment": "Element contents should in principle not be supported here, but we still want to highlight partial snippets",
            "include": "#element-contents"
        }

    ],
    "repository": {
        "block-comment": {
            "patterns": [
                {
                    "contentName": "comment.block.slint",
                    "begin": "(/\\*)",
                    "end": "(\\*/)",
                    "beginCaptures": {
                        "1": {
                            "name": "comment.block.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "comment.block.slint"
                        }
                    },
                    "patterns": [
                        {
                            "include": "#block-comment"
                        }
                    ]
                }
            ]
        },
        "line-comment": {
            "patterns": [
                {
                    "match": "//.*$",
                    "name": "comment.line.double-slash.slint"
                }
            ]
        },
        "comment": {
            "patterns": [
                {
                    "include": "#block-comment"
                },
                {
                    "include": "#line-comment"
                }
            ]
        },
        "import-list": {
            "patterns": [
                {
                    "match": "(?<!-)\\b(import)\\s*(\"[^\"]*\")\\s*;",
                    "captures": {
                        "1": {
                            "name": "keyword.other.import.slint"
                        },
                        "2": {
                            "name": "string.quoted.double.import-file.slint"
                        }
                    }
                },
                {
                    "begin": "(?<!-)\\b(import)\\s*(\\{)",
                    "end": "(\\})\\s*(from)\\s*(\"[^\"]*\")\\s*;",
                    "beginCaptures": {
                        "1": {
                            "name": "keyword.other.import.slint"
                        },
                        "2": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.curly.slint"
                        },
                        "2": {
                            "name": "keyword.other.from.slint"
                        },
                        "3": {
                            "name": "string.quoted.double.import-path.slint"
                        }
                    },
                    "patterns": [
                        {
                            "match": "(?<!-)\\bas\\b(?!-)",
                            "name": "keyword.other.as.slint"
                        },
                        {
                            "match": "(?<!-)[a-zA-Z_][a-zA-Z0-9_-]*(?!-)",
                            "name": "entity.name.type.import-list.slint"
                        },
                        {
                            "include": "#comment"
                        }
                    ]
                }
            ]
        },
        "export-list": {
            "patterns": [
                {
                    "begin": "(?<!-)\\b(export)\\s*(\\{)",
                    "end": "(\\})",
                    "beginCaptures": {
                        "1": {
                            "name": "keyword.other.export.slint"
                        },
                        "2": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "patterns": [
                        {
                            "match": "(?<!-)\\bas\\b(?!-)",
                            "name": "keyword.other.as.slint"
                        },
                        {
                            "match": "[a-zA-Z_][a-zA-Z0-9_-]*",
                            "name": "entity.name.type.export-list.slint"
                        },
                        {
                            "include": "#comment"
                        }
                    ]
                },
                {
                    "match": "\\s*(from)\\s*(\"[^\"]*\")\\s*;",
                    "captures": {
                        "1": {
                            "name": "keyword.other.from.slint"
                        },
                        "2": {
                            "name": "string.quoted.double.export-path.slint"
                        }
                    }
                }
            ]
        },
        "struct": {
            "patterns": [
                {
                    "begin": "(?<!-)\\b(struct)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)\\s*(\\{)",
                    "end": "(\\})",
                    "beginCaptures": {
                        "1": {
                            "name": "keyword.declaration.struct.slint"
                        },
                        "2": {
                            "name": "entity.name.type.struct.slint"
                        },
                        "3": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "patterns": [
                        {
                            "match": "\\s*([a-zA-Z_][a-zA-Z0-9_-]*)\\s*:\\s*([a-zA-Z_][a-zA-Z0-9_-]*)(\\s*,)?\\s*",
                            "captures": {
                                "1": {
                                    "name": "variable.other.struct.field.slint"
                                },
                                "2": {
                                    "name": "entity.name.type.struct.field.slint"
                                }
                            }
                        },
                        {
                            "include": "#comment"
                        }
                    ]
                }
            ]
        },
        "enum": {
            "patterns": [
                {
                    "begin": "(?<!-)\\b(enum)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)\\s*(\\{)",
                    "end": "(\\})",
                    "beginCaptures": {
                        "1": {
                            "name": "keyword.declaration.enum.slint"
                        },
                        "2": {
                            "name": "entity.name.type.enum.slint"
                        },
                        "3": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "patterns": [
                        {
                            "match": "([a-zA-Z_][a-zA-Z0-9_-]*)\\s*,?\\s*",
                            "captures": {
                                "1": {
                                    "name": "entity.name.type.enum.value.slint"
                                }
                            }
                        },
                        {
                            "include": "#comment"
                        }
                    ]
                }
            ]
        },
        "component": {
            "patterns": [
                {
                    "begin": "(?<!-)\\b(component)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)(\\s+(inherits)\\s+([a-zA-Z_][a-zA-Z0-9_-]*))?\\s*(\\{)",
                    "end": "(\\})",
                    "beginCaptures": {
                        "1": {
                            "name": "keyword.other.component.slint"
                        },
                        "2": {
                            "name": "entity.name.type.component.slint"
                        },
                        "4": {
                            "name": "keyword.other.inherits.slint"
                        },
                        "5": {
                            "name": "entity.other.inherited-class.component.slint"
                        },
                        "6": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "patterns": [
                        {
                            "include": "#element-contents"
                        }
                    ]
                }
            ]
        },
        "global": {
            "patterns": [
                {
                    "begin": "(?<!-)\\b(global)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)\\s*(\\{)",
                    "beginCaptures": {
                        "1": {
                            "name": "keyword.other.global.slint"
                        },
                        "2": {
                            "name": "entity.name.type.global.slint"
                        },
                        "3": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "end": "(\\})",
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "patterns": [
                        {
                            "include": "#element-contents"
                        }
                    ]
                }
            ]
        },
        "element-contents": {
            "patterns": [
                {
                    "include": "#comment"
                },
                {
                    "include": "#conditional-element"
                },
                {
                    "include": "#repeated-element"
                },
                {
                    "include": "#property-def"
                },
                {
                    "include": "#animate"
                },
                {
                    "include": "#element"
                },
                {
                    "include": "#function"
                },
                {
                    "include": "#property-set"
                },
                {
                    "include": "#code-block"
                },
                {
                    "include": "#states"
                },
                {
                    "include": "#callback-setup"
                },
                {
                    "include": "#function-call"
                },
                {
                    "include": "#expression"
                },
                {
                    "comment": "FIXME",
                    "match": "(?<!-)\\b(animate|states|transitions|private|public|pure|in|out|in-out|changed)\\b(?!-)",
                    "name": "keyword.other.extra.slint"
                }
            ]
        },
        "conditional-element": {
            "begin": "(?<!-)\\b(if)\\s+",
            "end": ":",
            "beginCaptures": {
                "1": {
                    "name": "keyword.control.conditional-element.slint"
                }
            },
            "patterns": [
                {
                    "include": "#expression"
                }
            ]
        },
        "repeated-element": {
            "begin": "(?<!-)\\b(for)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)(\\s*(\\[)\\s*([a-zA-Z_][a-zA-Z0-9_-]*)\\s*(\\]))?\\s+(in)\\b(?!-)",
            "end": ":",
            "beginCaptures": {
                "1": {
                    "name": "keyword.control.repeated-element.slint"
                },
                "2": {
                    "name": "variable.other.iterator.slint"
                },
                "4": {
                    "name": "punctuation.brackets.square.slint"
                },
                "5": {
                    "name": "variable.other.index.slint"
                },
                "6": {
                    "name": "punctuation.brackets.square.slint"
                },
                "7": {
                    "name": "keyword.control.in.slint"
                }
            },
            "patterns": [
                {
                    "include": "#expression"
                }
            ]
        },
        "element": {
            "begin": "(?<!-)(([a-zA-Z_][a-zA-Z0-9_-]*)\\s*(:=)\\s*)?([a-zA-Z_][a-zA-Z0-9_-]*)\\s*(\\{)",
            "end": "(\\})",
            "beginCaptures": {
                "2": {
                    "name": "entity.name.tag.element-id.slint"
                },
                "3": {
                    "name": "punctuation.assignment.element-id.slint"
                },
                "4": {
                    "name": "entity.name.type.element.slint"
                },
                "5": {
                    "name": "punctuation.brackets.curly.slint"
                }
            },
            "endCaptures": {
                "1": {
                    "name": "punctuation.brackets.curly.slint"
                }
            },
            "patterns": [
                {
                    "include": "#element-contents"
                }
            ]
        },
        "property-def": {
            "patterns": [
                {
                    "begin": "(?<!-)\\b((private|in|out|in-out)\\s+)?(property)\\b(?!-)",
                    "end": "(;|:|(<=>))",
                    "beginCaptures": {
                        "2": {
                            "name": "keyword.other.visibility.slint"
                        },
                        "3": {
                            "name": "keyword.other.property.slint"
                        }
                    },
                    "endCaptures": {
                        "2": {
                            "name": "punctuation.arrow.fat-double.slint"
                        }
                    },
                    "patterns": [
                        {
                            "match": "(<)([a-zA-Z_][a-zA-Z0-9_-]*)(>)",
                            "captures": {
                                "1": {
                                    "name": "punctuation.brackets.angle.slint"
                                },
                                "2": {
                                    "name": "entity.name.type.property.slint"
                                },
                                "3": {
                                    "name": "punctuation.brackets.angle.slint"
                                }
                            }
                        },
                        {
                            "match": "(?<!-)\\b([a-zA-Z_][a-zA-Z0-9_-]*)\\b(?!-)",
                            "captures": {
                                "1": {
                                    "name": "variable.other.property.slint"
                                }
                            }
                        }
                    ]
                }
            ]
        },
        "property-set": {
            "begin": "(?<!-)([a-zA-Z_][a-zA-Z0-9_-]*)\\s*(:)",
            "end": ";",
            "beginCaptures": {
                "1": {
                    "name": "variable.other.property.slint"
                }
            },
            "patterns": [
                {
                    "include": "#expression"
                }
            ]
        },
        "code-block": {
            "patterns": [
                {
                    "begin": "\\s*(\\{)",
                    "end": "(\\})\\s*",
                    "beginCaptures": {
                        "1": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "patterns": [
                        {
                            "include": "#code-block-contents"
                        }
                    ]
                }
            ]
        },
        "expression": {
            "patterns": [
                {
                    "include": "#value"
                },
                {
                    "match": "(?<!-)\\b(root|parent|self)(?!-)",
                    "captures": {
                        "1": {
                            "name": "variable.language.special-element.slint"
                        }
                    }
                }
            ]
        },
        "code-block-contents": {
            "patterns": [
                {
                    "include": "#comment"
                },
                {
                    "include": "#expression"
                },
                {
                    "match": "(?<!-)\\b(for|if|else|return)\\b(?!-)",
                    "name": "keyword.control.code-block.slint"
                },
                {
                    "match": "(=|;)",
                    "name": "punctuation.other.code-block.slint"
                },
                {
                    "include": "#function-call"
                },
                {
                    "include": "#code-block"
                }
            ]
        },
        "string": {
            "patterns": [
                {
                    "name": "string.quoted.double.slint",
                    "begin": "\"",
                    "end": "\"",
                    "patterns": [
                        {
                            "name": "constant.character.escape.untitled.slint",
                            "match": "\\\\(n|\\\\|u\\{\\d+\\})"
                        },
                        {
                            "name": "constant.character.escape.untitled.slint",
                            "begin": "\\\\\\{",
                            "end": "\\}",
                            "patterns": [
                                {
                                    "include": "#expression"
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        "color": {
            "patterns": [
                {
                    "match": "#([a-fA-F0-9]){3,8}",
                    "name": "constant.other.color.slint"
                },
                {
                    "match": "(?<!-)\\b((Colors)\\.)(aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen)\\b(?!-)",
                    "captures": {
                        "2": {
                            "name": "support.class.colors.slint"
                        },
                        "3": {
                            "name": "support.constant.colors.slint"
                        }
                    }
                }
            ]
        },
        "boolean": {
            "patterns": [
                {
                    "match": "(?<!-)\\b(true|false)\\b(?!-)",
                    "name": "constant.language.boolean.slint"
                }
            ]
        },
        "number": {
            "patterns": [
                {
                    "match": "(\\+|-)?\\d+(\\.\\d*)?(%|px|phx|pt|in|mm|cm|ms|s|deg|rad|rem|turn)?",
                    "name": "constant.numeric.slint"
                }
            ]
        },
        "value": {
            "patterns": [
                {
                    "include": "#string"
                },
                {
                    "include": "#color"
                },
                {
                    "include": "#number"
                },
                {
                    "include": "#boolean"
                },
                {
                    "begin": "(@(tr|linear-gradient|radial-gradient|conic-gradient|image-url))\\s*(\\()",
                    "end": "(\\))",
                    "beginCaptures": {
                        "1": {
                            "name": "support.function.macro.slint"
                        },
                        "3": {
                            "name": "punctuation.brackets.round.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "support.function.macro.slint"
                        },
                        "2": {
                            "name": "punctuation.brackets.round.slint"
                        }
                    },
                    "patterns": [
                        {
                            "include": "#expression"
                        }
                    ]
                }
            ]
        },
        "animate": {
            "patterns": [
                {
                    "begin": "(?<!-)\\b(animate)\\s*([a-zA-Z_][a-zA-Z0-9_-]*)\\s*(\\{)",
                    "end": "(\\})",
                    "beginCaptures": {
                        "1": {
                            "name": "keyword.other.animate.slint"
                        },
                        "2": {
                            "name": "variable.other.property.slint"
                        },
                        "3": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.curly.slint"
                        }
                    },
                    "patterns": [
                        {
                            "match": "(?<!-)\\b(delay|duration|iteration-count|easing|direction)\\s*:",
                            "captures": {
                                "1": {
                                    "name": "keyword.other.animate.setting.slint"
                                }
                            }
                        },
                        {
                            "include": "#expression"
                        },
                        {
                            "match": ";"
                        }
                    ]
                }
            ]
        },
        "states": {
            "patterns": [
                {
                    "begin": "(?<!-)\\b(states)\\s*(\\[)",
                    "end": "(\\])",
                    "beginCaptures": {
                        "1": {
                            "name": "keyword.other.states.slint"
                        },
                        "2": {
                            "name": "punctuation.brackets.square.slint"
                        }
                    },
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.square.slint"
                        }
                    },
                    "patterns": [
                        {
                            "begin": "(?<!-)([a-zA-Z_][a-zA-Z0-9_-]*)\\s+(when)\\s+",
                            "end": ":",
                            "beginCaptures": {
                                "1": {
                                    "name": "entity.name.tag.state.slint"
                                },
                                "2": {
                                    "name": "keyword.other.when.slint"
                                }
                            },
                            "endCaptures": {
                                "1": {
                                    "name": "punctuation.brackets.square.curly.slint"
                                }
                            },
                            "patterns": [
                                {
                                    "include": "#expression"
                                }
                            ]
                        },
                        {
                            "begin": "(\\{)",
                            "end": "(\\})",
                            "beginCaptures": {
                                "1": {
                                    "name": "punctuation.brackets.square.curly.slint"
                                }
                            },
                            "endCaptures": {
                                "1": {
                                    "name": "punctuation.brackets.square.curly.slint"
                                }
                            },
                            "patterns": [
                                {
                                    "include": "#property-set"
                                },
                                {
                                    "begin": "(?<!-)\\b(in|out)\\s+(\\{)",
                                    "end": "(\\})",
                                    "beginCaptures": {
                                        "1": {
                                            "name": "keyword.other.state-change.slint"
                                        },
                                        "2": {
                                            "name": "punctuation.brackets.square.curly.slint"
                                        }
                                    },
                                    "endCaptures": {
                                        "1": {
                                            "name": "punctuation.brackets.square.curly.slint"
                                        }
                                    },
                                    "patterns": [
                                        {
                                            "include": "#property-set"
                                        },
                                        {
                                            "include": "#animate"
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        "function": {
            "patterns": [
                {
                    "match": "(?<!-)\\b((pure)\\s+)?(function|callback)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)\\s*;\\s*",
                    "captures": {
                        "2": {
                            "name": "keyword.other.pure.slint"
                        },
                        "3": {
                            "name": "keyword.other.function.slint"
                        },
                        "4": {
                            "name": "entity.name.function.slint"
                        }
                    }
                },
                {
                    "begin": "(?<!-)\\b((pure)\\s+)?(function|callback)\\s+([a-zA-Z_][a-zA-Z0-9_-]*)\\s*(\\()",
                    "beginCaptures": {
                        "2": {
                            "name": "keyword.other.pure.slint"
                        },
                        "3": {
                            "name": "keyword.other.function.slint"
                        },
                        "4": {
                            "name": "entity.name.function.slint"
                        },
                        "5": {
                            "name": "punctuation.brackets.round.slint"
                        }
                    },
                    "end": "(\\))\\s*((->)\\s*([a-zA-Z_][a-zA-Z0-9_-]*))?(;|(=>))?",
                    "endCaptures": {
                        "1": {
                            "name": "punctuation.brackets.round.slint"
                        },
                        "3": {
                            "name": "keyword.operator.arrow.skinny.slint"
                        },
                        "4": {
                            "name": "entity.name.type.return-type.slint"
                        },
                        "6": {
                            "name": "keyword.operator.arrow.fat.slint"
                        }
                    },
                    "patterns": [
                        {
                            "match": "\\s*(([a-zA-Z_][a-zA-Z0-9_-]*)\\s*:\\s*)?([a-zA-Z_][a-zA-Z0-9_-]*)\\s*,?\\s*",
                            "captures": {
                                "2": {
                                    "name": "variable.parameter.function-argument.slint"
                                },
                                "3": {
                                    "name": "entity.name.type.function-argument.slint"
                                }
                            }
                        }
                    ]
                }
            ]
        },
        "function-call": {
            "patterns": [
                {
                    "begin": "(?<!-)([a-zA-Z_][a-zA-Z0-9_.-]*)\\s*\\(",
                    "beginCaptures": {
                        "1": {
                            "name": "entity.name.function.slint"
                        }
                    },
                    "end": "\\)",
                    "patterns": [
                        {
                            "include": "#expression"
                        },
                        {
                            "match": "\\s,\\s"
                        }
                    ]
                }
            ]
        },
        "callback-setup": {
            "patterns": [
                {
                    "match": "(?<!-)([a-zA-Z_][a-zA-Z0-9_-]*)\\s*=>",
                    "captures": {
                        "1": {
                            "name": "entity.name.function.slint"
                        }
                    }
                },
                {
                    "begin": "(?<!-)([a-zA-Z_][a-zA-Z0-9_-]*)\\s*\\(",
                    "beginCaptures": {
                        "1": {
                            "name": "entity.name.function.slint"
                        }
                    },
                    "end": "\\)\\s*=>",
                    "patterns": [
                        {
                            "include": "#expression"
                        },
                        {
                            "match": "\\s*,\\s*"
                        }
                    ]
                }
            ]
        }
    }
}
