From 2fb735982893bf61c39bc98f5980a57c307f669d Mon Sep 17 00:00:00 2001 From: Christoph Sax Date: Tue, 25 Jul 2023 06:12:57 +0200 Subject: feat(t32)!: update queries for new HLL node types - Lock grammar to version 2.1.1 - Update query for syntax hightlighting - fix missing locals query - reduce number of "(identifier) @variable" highlight queries - revert to capture @function.builtin for PRACTICE call expressions --- lua/nvim-treesitter/parsers.lua | 2 +- queries/t32/highlights.scm | 134 +++++++++++++++++++++++++++++++++------- queries/t32/locals.scm | 7 ++- 3 files changed, 118 insertions(+), 25 deletions(-) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 71b5eaf85..10884fcf4 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1512,7 +1512,7 @@ list.t32 = { install_info = { url = "https://codeberg.org/xasc/tree-sitter-t32", files = { "src/parser.c", "src/scanner.c" }, - revision = "1dd98248b01e4a3933c1b85b58bab0875e2ba437", + revision = "767f3c52fe649e4a6ab3551ac287e5b6038c9148", }, maintainers = { "@xasc" }, } diff --git a/queries/t32/highlights.scm b/queries/t32/highlights.scm index e5cba0125..d1543efd0 100644 --- a/queries/t32/highlights.scm +++ b/queries/t32/highlights.scm @@ -1,3 +1,4 @@ +; Keywords, punctuation and operators [ "=" "^^" @@ -28,50 +29,129 @@ "&" "->" "*" + "-=" + "+=" + "*=" + "/=" + "%=" + "|=" + "&=" + "^=" + ">>=" + "<<=" + "--" + "++" ] @operator [ - "(" - ")" - "{" - "}" - "[" - "]" + "(" + ")" + "{" + "}" + "[" + "]" ] @punctuation.bracket [ "," "." - ";" ] @punctuation.delimiter [ - (access_class) + "enum" + "struct" + "union" +] @keyword + +"sizeof" @keyword.operator + +[ + "const" + "volatile" +] @type.qualifier + + +; Operators in comma and conditional HLL expressions +(hll_comma_expression + "," @operator) + +(hll_conditional_expression + [ + "?" + ":" +] @conditional.ternary) + + +; Strings and others literal types +(access_class) @constant.builtin + +[ (address) (bitmask) (file_handle) - (frequency) (integer) + (hll_number_literal) +] @number + +[ + (float) + (frequency) (percentage) (time) -] @number +] @float -(float) @float +[ + (string) + (hll_string_literal) +] @string -(string) @string +(hll_escape_sequence) @string.escape (path) @string.special - (symbol) @symbol -(character) @character +[ + (character) + (hll_char_literal) +] @character + + +; Types in HLL expressions +[ + (hll_type_identifier) + (hll_type_descriptor) +] @type + +(hll_type_qualifier) @type.qualifier + +(hll_primitive_type) @type.builtin + + +; HLL expressions +(hll_call_expression + function: (identifier) @function.call) + +(hll_call_expression + function: (hll_field_expression + field: (hll_field_identifier) @function.call)) + + +; HLL variables +(identifier) @variable +(hll_field_identifier) @field + ; Commands (command_expression command: (identifier) @keyword) + (macro_definition command: (identifier) @keyword) +(call_expression + function: (identifier) @function.builtin) + + ; Returns ( (command_expression @@ -84,20 +164,23 @@ (#lua-match? @keyword.return "^[rR][eE][tT][uU][rR][nN]$") ) + ; Subroutine calls (subroutine_call_expression command: (identifier) @keyword subroutine: (identifier) @function.call) + ; Variables, constants and labels (macro) @variable.builtin -(internal_c_variable) @variable.builtin +(trace32_hll_variable) @variable.builtin (argument_list - (identifier) @constant) + (identifier) @constant.builtin) + ( - (argument_list (identifier) @constant.builtin) - (#lua-match? @constant.builtin "^[%%/][%l%u][%l%u%d.]*$") + (argument_list (identifier) @constant.builtin) + (#lua-match? @constant.builtin "^[%%/][%l%u][%l%u%d.]*$") ) ( @@ -106,24 +189,34 @@ arguments: (argument_list . (identifier) @label)) (#lua-match? @keyword "^[gG][oO][tT][oO]$") ) + (labeled_expression label: (identifier) @label) +(option_expression + (identifier) @constant.builtin) + +(format_expression + (identifier) @constant.builtin) + + ; Subroutine blocks (subroutine_block - command: (identifier) @keyword + command: (identifier) @keyword.function subroutine: (identifier) @function) (labeled_expression label: (identifier) @function (block)) + ; Parameter declarations (parameter_declaration command: (identifier) @keyword (identifier)? @constant.builtin macro: (macro) @parameter) + ; Control flow (if_block command: (identifier) @conditional) @@ -135,8 +228,5 @@ (repeat_block command: (identifier) @repeat) -(call_expression - function: (identifier) @function.builtin) -(type_identifier) @type (comment) @comment @spell diff --git a/queries/t32/locals.scm b/queries/t32/locals.scm index 7d18a7d3c..dc1f97fc2 100644 --- a/queries/t32/locals.scm +++ b/queries/t32/locals.scm @@ -13,7 +13,7 @@ (command_expression command: (identifier) arguments: (argument_list - variable: (identifier) @definition.var)) + declarator: (trace32_hll_variable) @definition.var)) ; Function definitions (subroutine_block @@ -32,4 +32,7 @@ (#set! reference.kind "function") ) -(macro) @reference +[ + (macro) + (trace32_hll_variable) +] @reference -- cgit v1.2.3-70-g09d2