From 72dacc5291a46967b874a6c48366dcd8278a5a4a Mon Sep 17 00:00:00 2001 From: Matthias Unterrainer Date: Sat, 17 Jan 2026 16:48:23 +0100 Subject: [PATCH] added highlights --- queries/highlights.scm | 192 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 queries/highlights.scm diff --git a/queries/highlights.scm b/queries/highlights.scm new file mode 100644 index 0000000..0f584cd --- /dev/null +++ b/queries/highlights.scm @@ -0,0 +1,192 @@ +; Keywords +"function" @keyword +"if" @keyword.conditional +"else" @keyword.conditional +"while" @keyword.repeat +"for" @keyword.repeat +"return" @keyword.return +"break" @keyword +"continue" @keyword +"print" @keyword +"const" @keyword +"mut" @keyword + +; Type keywords +"void" @type.builtin +"bool" @type.builtin +"char" @type.builtin +"string" @type.builtin +"int" @type.builtin +"uint" @type.builtin +"I8" @type.builtin +"int8_t" @type.builtin +"I16" @type.builtin +"int16_t" @type.builtin +"I32" @type.builtin +"int32_t" @type.builtin +"I64" @type.builtin +"int64_t" @type.builtin +"U8" @type.builtin +"uint8_t" @type.builtin +"U16" @type.builtin +"uint16_t" @type.builtin +"U32" @type.builtin +"uint32_t" @type.builtin +"U64" @type.builtin +"uint64_t" @type.builtin + +; Predefined constants +"NULL" @constant.builtin +"true" @boolean +"false" @boolean + +; Identifiers +(identifier) @variable + +; Function names +(function_definition + name: (identifier) @function) + +; Type specifiers +(type_specifier) @type +(int_type) @type.builtin +(uint_type) @type.builtin +(array_specifier) @type + +; Type qualifiers +(type_qualifier) @type.qualifier + +; Parameters +(parameter_declaration + name: (identifier) @parameter) + +; Literals +(integer_literal) @number +(signed_integer_literal) @number +(unsigned_integer_literal) @number +(string_literal) @string +(char_literal) @string.special + +; Operators +[ + "+" + "-" + "*" + "/" + "=" + "+=" + "-=" + "*=" + "/=" + "==" + "!=" + "<" + ">" + "&&" + "||" + "!" + "++" + "--" +] @operator + +(leq_operator) @operator +(geq_operator) @operator + +; Punctuation +[ + "(" + ")" + "[" + "]" + "{" + "}" + "," + ";" + "->" +] @punctuation.delimiter + +; Comments +(comment) @comment + +; Function calls +(postfix_expression + (base_expression (identifier) @function.call) + "(" (argument_expression_list)? ")") + +; Array access +(postfix_expression + (base_expression (identifier) @variable) + "[" (expression) @variable "]") + +; Variable declarations +(declaration + declarator: (init_declarator + name: (identifier) @variable)) + +; Variable assignments +(assignment_expression + (unary_expression + (postfix_expression + (base_expression (identifier) @variable))) + _ @operator) + +; Return statements +(jump_statement + "return" @keyword.return + (expression)? @variable) + +; Print statements +(print_statement + "print" @keyword + (expression) @variable) + +; If statements +(selection_statement + "if" @keyword.conditional + (expression) @variable + (statement_block) @block + (statement_block)? @block) + +; While loops +(iteration_statement + "while" @keyword.repeat + (expression) @variable + (secondary_block) @block) + +; For loops +(iteration_statement + "for" @keyword.repeat + (_)? @variable + (expression)? @variable + (expression)? @variable + (secondary_block) @block) + +; Function signatures +(function_signature + (parameter_list)? @parameter + (return_list)? @type) + +; Cast expressions +(cast_expression + (type_specifier_qualifier) @type + (cast_expression) @variable) + +; Binary expressions +[ + (additive_expression) + (multiplicative_expression) + (relational_expression) + (equality_expression) + (logical_expression) +] @operator + +; Unary expressions +(unary_expression + [ + "++" + "--" + "+" + "-" + "!" + ] @operator + (unary_expression) @variable)