From d8141a3df03d381c02cd0b6086fc49c7587f4c45 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 5 Feb 2024 17:34:07 +0100 Subject: [PATCH] ispc: Improve custom highlight, indent and local scopes --- runtime/queries/ispc/highlights.scm | 10 ++++------ runtime/queries/ispc/indents.scm | 12 +++++++---- runtime/queries/ispc/locals.scm | 31 +++++++++++++++++++---------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/runtime/queries/ispc/highlights.scm b/runtime/queries/ispc/highlights.scm index 6770d6bb9..7eda2a005 100644 --- a/runtime/queries/ispc/highlights.scm +++ b/runtime/queries/ispc/highlights.scm @@ -24,16 +24,14 @@ "foreach_tiled" "foreach_active" "foreach_unique" -] @repeat +] @keyword.control.repeat -[ - "cif" -] @conditional +"cif" @keyword.control.conditional [ "varying" "uniform" -] @type.qualifier +] @keyword.storage.modifier "__regcall" @attribute @@ -90,7 +88,7 @@ ; standard library built-in ((type_identifier) @type.builtin - (#lua-match? @type.builtin "^RNGState")) + (#match? @type.builtin "^RNGState")) (call_expression function: (identifier) @function.builtin diff --git a/runtime/queries/ispc/indents.scm b/runtime/queries/ispc/indents.scm index cc0829d5c..6dacfb3a9 100644 --- a/runtime/queries/ispc/indents.scm +++ b/runtime/queries/ispc/indents.scm @@ -1,7 +1,11 @@ ; inherits: c -((foreach_statement body: (_) @_body) @indent.begin - (#not-has-type? @_body compound_statement)) +(foreach_statement + body: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "all")) -((foreach_instance_statement body: (_) @_body) @indent.begin - (#not-has-type? @_body compound_statement)) +(foreach_instance_statement + body: (_) @indent + (#not-kind-eq? @indent "compound_statement") + (#set! "scope" "all")) diff --git a/runtime/queries/ispc/locals.scm b/runtime/queries/ispc/locals.scm index 8eca18c67..a446cd812 100644 --- a/runtime/queries/ispc/locals.scm +++ b/runtime/queries/ispc/locals.scm @@ -1,17 +1,26 @@ ; inherits: c -(reference_declarator - (identifier) @definition.var) +; Scopes +(template_function + name: (identifier) @local.definition) @local.scope + +[ + (foreach_statement) + (template_declaration) + (unmasked_statement) +] @local.scope +; Definitions +(reference_declarator + (identifier) @local.definition) (type_parameter_declaration - (type_identifier) @definition.type) -(template_declaration) @scope + (type_identifier) @local.definition) -(template_function - name: (identifier) @definition.function) @scope +(foreach_statement + range_start: (assignment_expression + left: (identifier) @local.definition)) +(foreach_instance_statement + initializer: (identifier) @local.definition) -[ - (foreach_statement) - (foreach_instance_statement) - (unmasked_statement) -] @scope +; References +(type_identifier) @local.reference