feat: add highlight, indent, fold, locals, and tags queries
This commit is contained in:
9
queries/folds.scm
Normal file
9
queries/folds.scm
Normal file
@@ -0,0 +1,9 @@
|
||||
[
|
||||
(block)
|
||||
(field_declaration_list)
|
||||
(enum_variant_list)
|
||||
(declaration_list)
|
||||
(match_block)
|
||||
(select_expression)
|
||||
(block_comment)
|
||||
] @fold
|
||||
@@ -1,2 +1,130 @@
|
||||
; Highlights for Rune
|
||||
; (populated in Task 10)
|
||||
; Types
|
||||
(type_identifier) @type
|
||||
|
||||
; Identifier conventions
|
||||
; All-caps identifiers = constants
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z\\d_]+$"))
|
||||
; Uppercase-start identifiers = constructors
|
||||
((identifier) @constructor
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
; Uppercase segment in scoped path = type
|
||||
((scoped_identifier path: (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
; Function calls
|
||||
(call_expression function: (identifier) @function.call)
|
||||
(call_expression function: (field_expression field: (field_identifier) @function.method.call))
|
||||
(call_expression function: (scoped_identifier name: (identifier) @function.call))
|
||||
|
||||
; Macro invocations
|
||||
(macro_invocation macro: (identifier) @function.macro "!" @function.macro)
|
||||
|
||||
; Function definitions
|
||||
(function_item name: (identifier) @function)
|
||||
|
||||
; Parameters
|
||||
(parameters (identifier) @variable.parameter)
|
||||
(closure_parameters (identifier) @variable.parameter)
|
||||
|
||||
; Comments
|
||||
(line_comment) @comment
|
||||
(block_comment) @comment
|
||||
|
||||
; Punctuation – brackets
|
||||
"(" @punctuation.bracket
|
||||
")" @punctuation.bracket
|
||||
"[" @punctuation.bracket
|
||||
"]" @punctuation.bracket
|
||||
"{" @punctuation.bracket
|
||||
"}" @punctuation.bracket
|
||||
|
||||
; Punctuation – delimiters
|
||||
"::" @punctuation.delimiter
|
||||
":" @punctuation.delimiter
|
||||
"." @punctuation.delimiter
|
||||
"," @punctuation.delimiter
|
||||
";" @punctuation.delimiter
|
||||
|
||||
; Keywords
|
||||
"async" @keyword
|
||||
"as" @keyword
|
||||
"await" @keyword
|
||||
"break" @keyword
|
||||
"continue" @keyword
|
||||
"else" @keyword
|
||||
"enum" @keyword
|
||||
"fn" @keyword
|
||||
"for" @keyword
|
||||
"if" @keyword
|
||||
"in" @keyword
|
||||
"is" @keyword
|
||||
"let" @keyword
|
||||
"loop" @keyword
|
||||
"match" @keyword
|
||||
"mod" @keyword
|
||||
"not" @keyword
|
||||
"pub" @keyword
|
||||
"return" @keyword
|
||||
"select" @keyword
|
||||
"struct" @keyword
|
||||
"use" @keyword
|
||||
"while" @keyword
|
||||
"yield" @keyword
|
||||
(crate) @keyword
|
||||
(super) @keyword
|
||||
(self) @variable.builtin
|
||||
|
||||
; Literals – strings
|
||||
(string_literal) @string
|
||||
(string_content) @string
|
||||
(char_literal) @character
|
||||
(template_literal) @string
|
||||
(template_content) @string
|
||||
(escape_sequence) @string.escape
|
||||
(interpolation "${" @punctuation.special "}" @punctuation.special)
|
||||
|
||||
; Literals – scalars
|
||||
(boolean_literal) @constant.builtin
|
||||
(integer_literal) @number
|
||||
(float_literal) @number.float
|
||||
|
||||
; Attributes
|
||||
(attribute_item) @attribute
|
||||
(inner_attribute_item) @attribute
|
||||
|
||||
; Operators
|
||||
"!" @operator
|
||||
"*" @operator
|
||||
"+" @operator
|
||||
"-" @operator
|
||||
"/" @operator
|
||||
"%" @operator
|
||||
"&" @operator
|
||||
"|" @operator
|
||||
"^" @operator
|
||||
"=" @operator
|
||||
"==" @operator
|
||||
"!=" @operator
|
||||
"<" @operator
|
||||
">" @operator
|
||||
"<=" @operator
|
||||
">=" @operator
|
||||
"<<" @operator
|
||||
">>" @operator
|
||||
"+=" @operator
|
||||
"-=" @operator
|
||||
"*=" @operator
|
||||
"/=" @operator
|
||||
"%=" @operator
|
||||
"&=" @operator
|
||||
"|=" @operator
|
||||
"^=" @operator
|
||||
"<<=" @operator
|
||||
">>=" @operator
|
||||
"&&" @operator
|
||||
"||" @operator
|
||||
"=>" @operator
|
||||
".." @operator
|
||||
"..=" @operator
|
||||
"..." @operator
|
||||
|
||||
18
queries/indents.scm
Normal file
18
queries/indents.scm
Normal file
@@ -0,0 +1,18 @@
|
||||
[
|
||||
(block)
|
||||
(field_declaration_list)
|
||||
(enum_variant_list)
|
||||
(declaration_list)
|
||||
(match_block)
|
||||
(arguments)
|
||||
(parameters)
|
||||
(array_expression)
|
||||
(object_literal)
|
||||
(select_expression)
|
||||
] @indent
|
||||
|
||||
[
|
||||
"}"
|
||||
"]"
|
||||
")"
|
||||
] @outdent
|
||||
18
queries/locals.scm
Normal file
18
queries/locals.scm
Normal file
@@ -0,0 +1,18 @@
|
||||
; Scopes
|
||||
(block) @local.scope
|
||||
(function_item) @local.scope
|
||||
(closure_expression) @local.scope
|
||||
(for_expression) @local.scope
|
||||
(while_expression) @local.scope
|
||||
(loop_expression) @local.scope
|
||||
(if_expression) @local.scope
|
||||
(match_arm) @local.scope
|
||||
|
||||
; Definitions
|
||||
(let_declaration pattern: (identifier) @local.definition)
|
||||
(parameters (identifier) @local.definition)
|
||||
(closure_parameters (identifier) @local.definition)
|
||||
(for_expression pattern: (identifier) @local.definition)
|
||||
|
||||
; References
|
||||
(identifier) @local.reference
|
||||
@@ -1,2 +1,7 @@
|
||||
; Tags for Rune
|
||||
; (populated in Task 11)
|
||||
(struct_item name: (type_identifier) @name) @definition.class
|
||||
(enum_item name: (type_identifier) @name) @definition.class
|
||||
(function_item name: (identifier) @name) @definition.function
|
||||
(mod_item name: (identifier) @name) @definition.module
|
||||
(call_expression function: (identifier) @name) @reference.call
|
||||
(call_expression function: (field_expression field: (field_identifier) @name)) @reference.call
|
||||
(macro_invocation macro: (identifier) @name) @reference.call
|
||||
|
||||
Reference in New Issue
Block a user