diff --git a/queries/scl/folds.scm b/queries/scl/folds.scm index 09a87c5..0b2a9b3 100644 --- a/queries/scl/folds.scm +++ b/queries/scl/folds.scm @@ -3,12 +3,21 @@ [ (organization_block) (function_block) + (function) + (type_definition) + (data_block) (var_declaration) + (var_temp_declaration) + (var_constant_declaration) + (var_retain_declaration) + (var_non_retain_declaration) + (var_db_specific_declaration) (if_statement) (case_statement) (for_statement) (while_statement) (repeat_statement) (region_statement) + (struct_type) (block_comment) ] @fold diff --git a/queries/scl/highlights.scm b/queries/scl/highlights.scm index 717d26e..09f5892 100644 --- a/queries/scl/highlights.scm +++ b/queries/scl/highlights.scm @@ -1,66 +1,99 @@ ; SCL highlights +; Comments (line_comment) @comment (block_comment) @comment (c_style_comment) @comment +; Literals (number) @number (hex_number) @number -(string) @string +(binary_number) @number +(octal_number) @number (time_value) @number +(date_literal) @number +(bool_literal) @constant.builtin +(typed_int_literal) @number +(wstring_literal) @string +(char_literal) @character +(string) @string +; Prefix (prefix) @punctuation.special +; Variables and identifiers (identifier) @variable -; FB instance calls - highlight instance name as type +; FB instance calls (fb_call instance: (prefixed_identifier (identifier) @type)) (fb_call instance: (identifier) @type) -; FB parameter names (IN :=, PT :=, etc.) +; FB parameter names (fb_parameter name: (identifier) @property) ; Function call names (function_call (identifier) @function) +(function_call + (string) @function) + +; Method call names +(method_callee + (identifier) @function) ; Variable declarations (var_item name: (identifier) @variable) -; Type references in declarations +; Type references (type (identifier) @type) - (type_builtin) @type.builtin +; Keywords and operators (keyword) @keyword (constant) @constant.builtin (operator) @operator -(assignment) @operator -(binary_expression) @operator -(unary_expression) @operator +; Block names +(organization_block + name: (string) @type) +(function_block + name: (string) @type) +(function + name: (string) @function) +(data_block + name: (string) @type) +(type_definition + name: (string) @type) +; Access (field_access "." (identifier) @property) - (array_access) @property +(bit_access) @property +; Attributes (attribute_list) @attribute (attribute) @attribute (attribute_value) @string -(var_item) @property +; Statements +(assignment) @operator +(binary_expression) @operator +(unary_expression) @operator +(chained_assignment) @operator +; Function/FB calls (function_call) @function.call (fb_call) @function.call +; Control flow (if_statement) @conditional (elsif_clause) @conditional (else_clause) @conditional @@ -71,6 +104,13 @@ (while_statement) @repeat (repeat_statement) @repeat +(return_statement) @keyword +(goto_statement) @keyword + +; Title +(title_statement) @comment + +; Punctuation ";" @punctuation.delimiter ":" @punctuation.delimiter "," @punctuation.delimiter @@ -80,15 +120,22 @@ "]" @punctuation.bracket "." @punctuation.delimiter +; Operators ":=" @operator "=>" @operator +"+=" @operator +"-=" @operator +"*=" @operator +"/=" @operator +"&=" @operator +"|=" @operator +"^=" @operator "=" @operator "<>" @operator "<" @operator ">" @operator "<=" @operator ">=" @operator - "+" @operator "-" @operator "*" @operator diff --git a/queries/scl/indents.scm b/queries/scl/indents.scm index cbc57f0..b12f45e 100644 --- a/queries/scl/indents.scm +++ b/queries/scl/indents.scm @@ -1,10 +1,26 @@ ; Indentation rules for SCL -; Indent after block keywords +; Indent after block definitions [ (organization_block) (function_block) + (function) + (type_definition) + (data_block) +] @indent.begin + +; Indent after VAR sections +[ (var_declaration) + (var_temp_declaration) + (var_constant_declaration) + (var_retain_declaration) + (var_non_retain_declaration) + (var_db_specific_declaration) +] @indent.begin + +; Indent after control structures +[ (if_statement) (case_statement) (for_statement) @@ -13,12 +29,16 @@ (region_statement) ] @indent.begin -; Indent after THEN, DO, etc. +; Indent after STRUCT in UDTs and inline structs +(struct_type) @indent.begin + +; Indent after THEN, DO, ELSE, ELSIF, BEGIN [ "THEN" "DO" "ELSE" "ELSIF" + (keyword) @indent.branch ] @indent.branch ; Outdent at end keywords @@ -30,8 +50,12 @@ "END_WHILE" "END_REPEAT" "END_REGION" + "END_STRUCT" "END_ORGANIZATION_BLOCK" "END_FUNCTION_BLOCK" + "END_FUNCTION" + "END_TYPE" + "END_DATA_BLOCK" ] @indent.end ; Outdent for ELSE and ELSIF diff --git a/queries/scl/locals.scm b/queries/scl/locals.scm index e3b5d2c..911e0e7 100644 --- a/queries/scl/locals.scm +++ b/queries/scl/locals.scm @@ -1,15 +1,39 @@ -; Local variable scoping for SCL - matches grammar.js structure +; Local variable scoping for SCL ; Variable declarations define local variables (var_item name: (identifier) @definition.var) -; Variable sections create scopes -(var_declaration) @local.scope - ; Blocks create scopes (organization_block) @local.scope (function_block) @local.scope +(function) @local.scope +(type_definition) @local.scope +(data_block) @local.scope -; Identifiers are references -(identifier) @reference +; VAR sections create scopes +(var_declaration) @local.scope +(var_temp_declaration) @local.scope +(var_constant_declaration) @local.scope +(var_retain_declaration) @local.scope +(var_non_retain_declaration) @local.scope +(var_db_specific_declaration) @local.scope + +; Struct types create scopes +(struct_type) @local.scope + +; Block names are definitions +(organization_block + name: (string) @definition.function) +(function_block + name: (string) @definition.function) +(function + name: (string) @definition.function) +(data_block + name: (string) @definition.class) +(type_definition + name: (string) @definition.type) + +; References +(prefixed_identifier + (identifier) @reference) diff --git a/queries/scl/tags.scm b/queries/scl/tags.scm index 0f9aebc..8c4ec4f 100644 --- a/queries/scl/tags.scm +++ b/queries/scl/tags.scm @@ -1,13 +1,25 @@ -; Tag queries for SCL - matches grammar.js structure +; Tag queries for SCL - symbol navigation ; Organization blocks (organization_block name: (string) @name) @definition.function -; Function blocks +; Function blocks (function_block name: (string) @name) @definition.function +; Functions +(function + name: (string) @name) @definition.function + +; Data blocks +(data_block + name: (string) @name) @definition.class + +; Type definitions (UDTs) +(type_definition + name: (string) @name) @definition.type + ; Variable definitions within blocks (var_item name: (identifier) @name @@ -25,3 +37,14 @@ (function_call (string) @name) @reference.call + +; FB calls (references) +(fb_call + instance: (identifier) @name) @reference.call + +(fb_call + instance: (prefixed_identifier + (identifier) @name)) @reference.call + +; Region statements +(region_statement) @definition.module