aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Sax <christoph.sax@mailbox.org>2023-07-25 06:12:57 +0200
committerChristian Clason <c.clason@uni-graz.at>2023-07-30 19:29:33 +0200
commit2fb735982893bf61c39bc98f5980a57c307f669d (patch)
tree78a91e8f53929b06ef409f5824d7ae73c3183b5b
parentfeat(sql): add new keywords (diff)
downloadnvim-treesitter-2fb735982893bf61c39bc98f5980a57c307f669d.tar
nvim-treesitter-2fb735982893bf61c39bc98f5980a57c307f669d.tar.gz
nvim-treesitter-2fb735982893bf61c39bc98f5980a57c307f669d.tar.bz2
nvim-treesitter-2fb735982893bf61c39bc98f5980a57c307f669d.tar.lz
nvim-treesitter-2fb735982893bf61c39bc98f5980a57c307f669d.tar.xz
nvim-treesitter-2fb735982893bf61c39bc98f5980a57c307f669d.tar.zst
nvim-treesitter-2fb735982893bf61c39bc98f5980a57c307f669d.zip
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
-rw-r--r--lua/nvim-treesitter/parsers.lua2
-rw-r--r--queries/t32/highlights.scm134
-rw-r--r--queries/t32/locals.scm7
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