diff --git a/languages/nim/queries/highlights.scm b/languages/nim/queries/highlights.scm index 70723d6b..a87701f6 100644 --- a/languages/nim/queries/highlights.scm +++ b/languages/nim/queries/highlights.scm @@ -1,73 +1,190 @@ -((ident) @support.type.nim - (#match? @support.type.nim "^[A-Z].*$")) -(typeDesc (primaryTypeDesc (symbol (ident) @storage.type))) -((ident) @storage.type - (#match? @storage.type "^(int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float|float32|float64|bool|string|char|typed|untyped|openArray|seq|array|set)$")) -((ident) @keyword - (#match? @keyword "^(end|echo|declared|low|high|ord|async|await|if|else|elif|some|none|void|return|for|try|except|when|let|var|const)$")) - -(routine (keyw) (symbol (ident) @variable.function)) - -"=" @punctuation -":" @punctuation -"." @punctuation -"," @punctuation -";" @punctuation -"(" @punctuation -")" @punctuation -"[" @punctuation -"]" @punctuation -"{" @punctuation -"}" @punctuation - -(primary - (primarySuffix) @variable.function - . - (primarySuffix (functionCall)) -) -(primary - . - (_) @variable.function - . - (primarySuffix (functionCall)) -) - -(ident) @variable +; SPDX-FileCopyrightText: 2023 Leorize +; SPDX-License-Identifier: MPL-2.0 -[ - (str_lit) - (char_lit) - (rstr_lit) - (triplestr_lit) - (generalized_str_lit) - (interpolated_str_lit) -] @string +; Punctuations +[ "." ";" "," ":" ] @punctuation.delimiter +[ "(" ")" "[" "]" "{" "}" "{." ".}" ] @punctuation.bracket -[ - (int_lit) - (float_lit) - (float_suffix) - (int_suffix) -] @constant.numeric +; Operator by default, but could be overriden +[ "=" ] @operator + +; Special +(blank_identifier) @variable.builtin + +; Calls +(call + function: [ + (identifier) @function.call + (dot_expression + right: (identifier) @function.call) + ]) +(generalized_string + function: [ + (identifier) @function.call + (dot_expression + right: (identifier) @function.call) + ]) -(customNumericLitSuffix) @support.type +; Declarations +(exported_symbol "*" @type.qualifier) +(_ "=" @punctuation.delimiter [body: (_) value: (_)]) +(proc_declaration name: (_) @function) +(func_declaration name: (_) @function) +(converter_declaration name: (_) @function) +(method_declaration name: (_) @method) +(template_declaration name: (_) @function.macro) +(macro_declaration name: (_) @function.macro) +(symbol_declaration name: (_) @variable) +(parameter_declaration + (symbol_declaration_list + (symbol_declaration name: (_) @parameter))) +(_ + [ + type: [ + (type_expression (identifier)) + (type_expression (accent_quoted (identifier))) + ] @type + return_type: [ + (type_expression (identifier)) + (type_expression (accent_quoted (identifier))) + ] @type + ]) +; Exceptions [ - "true" - "false" -] @constant.numeric + "try" + "except" + "finally" + "raise" +] @exception +(except_branch values: (expression_list + [ + (identifier) @type + (infix_expression + left: (identifier) @type + operator: "as" + right: (identifier) @variable) + ])) + +; Expressions +(dot_expression + right: (identifier) @field) + +; Literal/comments [ (comment) - (docComment) + (block_comment) ] @comment -(operator) @keyword.operator +[ + (documentation_comment) + (block_documentation_comment) +] @comment.documentation -(keyw) @keyword +(interpreted_string_literal) @string +(long_string_literal) @string +(raw_string_literal) @string +(generalized_string) @string +(char_literal) @character +(escape_sequence) @string.escape +(integer_literal) @number +(float_literal) @float +(custom_numeric_literal) @number +(nil_literal) @constant.builtin +; Keyword [ - "nil" + "if" + "when" + "case" + "elif" "else" +] @conditional + +(of_branch "of" @conditional) + +[ + "import" + "include" + "export" +] @include + +(import_from_statement "from" @include) +(except_clause "except" @include) + +[ + "for" + "while" + "continue" + "break" +] @repeat + +(for "in" @repeat) + +[ + "macro" + "template" + "const" + "let" + "var" + "asm" + "bind" + "block" + "concept" + "defer" + "discard" + "distinct" + "do" + "enum" + "mixin" + "nil" + "object" + "out" + "ptr" + "ref" + "static" + "tuple" + "type" ] @keyword +[ + "proc" + "func" + "method" + "converter" + "iterator" +] @keyword.function + +[ + "and" + "or" + "xor" + "not" + "div" + "mod" + "shl" + "shr" + "from" + "as" + "of" + "in" + "notin" + "is" + "isnot" + "cast" +] @keyword.operator + +[ + "return" + "yield" +] @keyword.return + +; Operators +(infix_expression operator: _ @operator) +(prefix_expression operator: _ @operator) + +((identifier) @type + (#match? @type "^[A-Z].*$")) +((identifier) @type + (#match? @type "^(openArray|typedesc)$")) \ No newline at end of file diff --git a/themes/tokyo-night-color-theme.json b/themes/tokyo-night-color-theme.json index 197911a6..135c79c8 100644 --- a/themes/tokyo-night-color-theme.json +++ b/themes/tokyo-night-color-theme.json @@ -492,6 +492,8 @@ "punctuation.definition.constant", "constant.language", "constant.numeric", + "number", + "float", "support.constant" // "constant.language.null", // "constant.language.undefined", @@ -509,6 +511,7 @@ "name": "String, Symbols", "scope": [ "string", + "character", "constant.other.symbol", "constant.other.key", "meta.attribute-selector" @@ -607,7 +610,9 @@ "keyword.control.as", "keyword.other", "keyword.operator.bitwise.shift", + "type.qualifier", "punctuation", + "operator", "expression.embbeded.vue punctuation.definition.tag", "text.html.twig meta.tag.inline.any.html", "meta.tag.template.value.twig meta.function.arguments.twig", @@ -638,6 +643,7 @@ "keyword.control.export", "keyword.control.from", "keyword.control.default", + "include", "meta.import keyword.other" ], "settings": { @@ -649,6 +655,8 @@ "scope": [ "keyword", "keyword.control", + "conditional", + "repeat", "keyword.other.important" ], "settings": { @@ -728,6 +736,15 @@ "foreground": "#c0caf5" } }, + { + "name": "Builtin Variables", + "scope": [ + "variable.builtin" + ], + "settings": { + "foreground": "#a4afdd" + } + }, { "name": "Variable Array Key", "scope": "meta.array.literal variable", @@ -738,6 +755,7 @@ { "name": "Object Key", "scope": [ + "field", "meta.object-literal.key", "entity.name.type.hcl", "string.alias.graphql", @@ -807,6 +825,9 @@ "name": "Function Definition", "scope": [ "entity.name.function", + "function", + "method", + "function.call", "variable.other.enummember", "meta.function-call", "meta.function-call entity.name.function", @@ -823,6 +844,7 @@ "scope": [ "variable.parameter.function.language.special", "variable.parameter", + "parameter", "meta.function.parameters punctuation.definition.variable", "meta.function.parameter variable" ], @@ -869,6 +891,7 @@ "scope": [ "support.class", "support.type", + "type", "variable.other.readwrite.alias", "support.orther.namespace.use.php", "meta.use.php",