aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/squirrel
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-06-12 09:54:30 -0600
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit692b051b09935653befdb8f7ba8afdb640adf17b (patch)
tree167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/squirrel
parentfeat(c-family): inherit injections (diff)
downloadnvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/squirrel')
-rw-r--r--runtime/queries/squirrel/folds.scm23
-rw-r--r--runtime/queries/squirrel/highlights.scm316
-rw-r--r--runtime/queries/squirrel/indents.scm63
-rw-r--r--runtime/queries/squirrel/injections.scm12
-rw-r--r--runtime/queries/squirrel/locals.scm75
5 files changed, 489 insertions, 0 deletions
diff --git a/runtime/queries/squirrel/folds.scm b/runtime/queries/squirrel/folds.scm
new file mode 100644
index 000000000..c2903cc66
--- /dev/null
+++ b/runtime/queries/squirrel/folds.scm
@@ -0,0 +1,23 @@
+[
+ (class_declaration)
+ (function_declaration)
+ (member_declaration)
+ (enum_declaration)
+ (array)
+ (block)
+ (table)
+ (anonymous_function)
+ (parenthesized_expression)
+ (string)
+ (verbatim_string)
+ (comment)
+ (if_statement)
+ (else_statement)
+ (while_statement)
+ (do_while_statement)
+ (switch_statement)
+ (for_statement)
+ (foreach_statement)
+ (try_statement)
+ (catch_statement)
+] @fold
diff --git a/runtime/queries/squirrel/highlights.scm b/runtime/queries/squirrel/highlights.scm
new file mode 100644
index 000000000..03acacadc
--- /dev/null
+++ b/runtime/queries/squirrel/highlights.scm
@@ -0,0 +1,316 @@
+; Keywords
+[
+ "clone"
+ "delete"
+ "extends"
+ "rawcall"
+ "resume"
+ "var"
+] @keyword
+
+[
+ "class"
+ "enum"
+] @keyword.type
+
+"function" @keyword.function
+
+[
+ "in"
+ "instanceof"
+ "typeof"
+] @keyword.operator
+
+[
+ "return"
+ "yield"
+] @keyword.return
+
+((global_variable
+ "::"
+ (_) @keyword.coroutine)
+ (#any-of? @keyword.coroutine "suspend" "newthread"))
+
+; Conditionals
+[
+ "if"
+ "else"
+ "switch"
+ "case"
+ "default"
+ "break"
+] @keyword.conditional
+
+; Repeats
+[
+ "for"
+ "foreach"
+ "do"
+ "while"
+ "continue"
+] @keyword.repeat
+
+; Exceptions
+[
+ "try"
+ "catch"
+ "throw"
+] @keyword.exception
+
+; Storageclasses
+"local" @keyword.modifier
+
+; Qualifiers
+[
+ "static"
+ "const"
+] @keyword.modifier
+
+; Variables
+[
+ (identifier)
+ (global_variable)
+] @variable
+
+(local_declaration
+ (identifier) @variable
+ .
+ "=")
+
+((identifier) @variable.builtin
+ (#any-of? @variable.builtin "base" "this" "vargv"))
+
+; Parameters
+(parameter
+ .
+ (identifier) @variable.parameter)
+
+; Properties (Slots)
+(deref_expression
+ "."
+ .
+ (identifier) @variable.member)
+
+(member_declaration
+ (identifier) @variable.member
+ .
+ "=")
+
+((table_slot
+ .
+ (identifier) @variable.member
+ .
+ [
+ "="
+ ":"
+ ])
+ (#set! priority 105))
+
+; Types
+((identifier) @type
+ (#lua-match? @type "^[A-Z]"))
+
+(class_declaration
+ (identifier) @type
+ "extends"?
+ .
+ (identifier)? @type)
+
+(enum_declaration
+ (identifier) @type)
+
+; Attributes
+(attribute_declaration
+ left: (identifier) @attribute)
+
+; Functions & Methods
+(member_declaration
+ (function_declaration
+ "::"?
+ (_) @function.method
+ .
+ "("
+ (_)?
+ ")"))
+
+((function_declaration
+ "::"?
+ (_) @function
+ .
+ "("
+ (_)?
+ ")")
+ (#not-has-ancestor? @function member_declaration))
+
+(call_expression
+ function: (identifier) @function.call)
+
+(call_expression
+ function: (deref_expression
+ "."
+ .
+ (identifier) @function.call))
+
+(call_expression
+ (global_variable
+ "::"
+ (_) @function.call))
+
+(_
+ (identifier) @function
+ "="
+ (lambda_expression
+ "@" @string.special.symbol))
+
+(call_expression
+ [
+ function: (identifier) @function.builtin
+ function: (global_variable
+ "::"
+ (_) @function.builtin)
+ function: (deref_expression
+ "."
+ (_) @function.builtin)
+ ]
+ (#any-of? @function.builtin
+ ; General Methods
+ "assert" "array" "callee" "collectgarbage" "compilestring" "enabledebughook" "enabledebuginfo"
+ "error" "getconsttable" "getroottable" "print" "resurrectunreachable" "setconsttable"
+ "setdebughook" "seterrorhandler" "setroottable" "type"
+ ; Hidden Methods
+ "_charsize_" "_intsize_" "_floatsize_" "_version_" "_versionnumber_"
+ ; Number Methods
+ "tofloat" "tostring" "tointeger" "tochar"
+ ; String Methods
+ "len" "slice" "find" "tolower" "toupper"
+ ; Table Methods
+ "rawget" "rawset" "rawdelete" "rawin" "clear" "setdelegate" "getdelegate" "filter" "keys"
+ "values"
+ ; Array Methods
+ "append" "push" "extend" "pop" "top" "insert" "remove" "resize" "sort" "reverse" "map" "apply"
+ "reduce"
+ ; Function Methods
+ "call" "pcall" "acall" "pacall" "setroot" "getroot" "bindenv" "getinfos"
+ ; Class Methods
+ "instance" "getattributes" "setattributes" "newmember" "rawnewmember"
+ ; Class Instance Methods
+ "getclass"
+ ; Generator Methods
+ "getstatus"
+ ; Thread Methods
+ "call" "wakeup" "wakeupthrow" "getstackinfos"
+ ; Weak Reference Methods
+ "ref" "weakref"))
+
+(member_declaration
+ "constructor" @constructor)
+
+; Constants
+(const_declaration
+ "const"
+ .
+ (identifier) @constant)
+
+(enum_declaration
+ "{"
+ .
+ (identifier) @constant)
+
+((identifier) @constant
+ (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
+
+; Operators
+[
+ "+"
+ "-"
+ "*"
+ "/"
+ "%"
+ "||"
+ "&&"
+ "|"
+ "^"
+ "&"
+ "=="
+ "!="
+ "<=>"
+ ">"
+ ">="
+ "<="
+ "<"
+ "<<"
+ ">>"
+ ">>>"
+ "="
+ "<-"
+ "+="
+ "-="
+ "*="
+ "/="
+ "%="
+ "~"
+ "!"
+ "++"
+ "--"
+] @operator
+
+; Punctuation
+[
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "["
+ "]"
+] @punctuation.bracket
+
+[
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ "</"
+ "/>"
+] @punctuation.bracket
+
+[
+ "."
+ ","
+ ";"
+ ":"
+] @punctuation.delimiter
+
+[
+ "::"
+ "..."
+] @punctuation.special
+
+; Ternaries
+(ternary_expression
+ "?" @keyword.conditional.ternary
+ ":" @keyword.conditional.ternary)
+
+; Literals
+(string) @string
+
+(verbatim_string) @string.special
+
+(char) @character
+
+(escape_sequence) @string.escape
+
+(integer) @number
+
+(float) @number.float
+
+(bool) @boolean
+
+(null) @constant.builtin
+
+; Comments
+(comment) @comment @spell
+
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
diff --git a/runtime/queries/squirrel/indents.scm b/runtime/queries/squirrel/indents.scm
new file mode 100644
index 000000000..00245d6ae
--- /dev/null
+++ b/runtime/queries/squirrel/indents.scm
@@ -0,0 +1,63 @@
+[
+ (class_declaration)
+ (function_declaration)
+ (enum_declaration)
+ (array)
+ (block)
+ (table)
+ (anonymous_function)
+ (parenthesized_expression)
+ (while_statement)
+ (switch_statement)
+ (for_statement)
+ (foreach_statement)
+ ; (try_statement)
+ (catch_statement)
+] @indent.begin
+
+((if_statement)
+ (ERROR
+ "else") @indent.begin)
+
+(if_statement
+ condition: (_) @indent.begin)
+
+(if_statement
+ consequence: (_)
+ (else_statement) @indent.begin)
+
+(do_while_statement
+ "do"
+ (_) @indent.begin)
+
+(try_statement
+ (_) @indent.begin
+ (catch_statement) @indent.begin)
+
+[
+ "{"
+ "}"
+] @indent.branch
+
+[
+ "("
+ ")"
+] @indent.branch
+
+[
+ "["
+ "]"
+] @indent.branch
+
+[
+ "}"
+ ")"
+ "]"
+] @indent.end
+
+[
+ (ERROR)
+ (comment)
+ (string)
+ (verbatim_string)
+] @indent.auto
diff --git a/runtime/queries/squirrel/injections.scm b/runtime/queries/squirrel/injections.scm
new file mode 100644
index 000000000..578a9eeca
--- /dev/null
+++ b/runtime/queries/squirrel/injections.scm
@@ -0,0 +1,12 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
+
+((verbatim_string) @injection.content
+ (#lua-match? @injection.content "^@\"<html")
+ (#set! injection.language "html")
+ (#offset! @injection.content 0 2 0 -1))
+
+((verbatim_string) @injection.content
+ (#lua-match? @injection.content "@\"<!DOCTYPE html>")
+ (#set! injection.language "html")
+ (#offset! @injection.content 0 2 0 -1))
diff --git a/runtime/queries/squirrel/locals.scm b/runtime/queries/squirrel/locals.scm
new file mode 100644
index 000000000..e5fce7d57
--- /dev/null
+++ b/runtime/queries/squirrel/locals.scm
@@ -0,0 +1,75 @@
+; Scopes
+[
+ (script)
+ (class_declaration)
+ (enum_declaration)
+ (function_declaration)
+ (attribute_declaration)
+ (array)
+ (block)
+ (table)
+ (anonymous_function)
+ (parenthesized_expression)
+ (if_statement)
+ (else_statement)
+ (while_statement)
+ (do_while_statement)
+ (switch_statement)
+ (for_statement)
+ (foreach_statement)
+ (try_statement)
+ (catch_statement)
+] @local.scope
+
+; References
+[
+ (identifier)
+ (global_variable)
+] @local.reference
+
+; Definitions
+(const_declaration
+ .
+ (identifier) @local.definition.constant)
+
+(enum_declaration
+ .
+ (identifier) @local.definition.enum)
+
+(member_declaration
+ (identifier) @local.definition.field
+ .
+ "=")
+
+(table_slot
+ .
+ (identifier) @local.definition.field
+ .
+ [
+ "="
+ ":"
+ ])
+
+((function_declaration
+ .
+ (identifier) @local.definition.function)
+ (#not-has-ancestor? @local.definition.function member_declaration))
+
+(member_declaration
+ (function_declaration
+ .
+ (identifier) @local.definition.method))
+
+(class_declaration
+ .
+ (identifier) @local.definition.type)
+
+(var_statement
+ "var"
+ .
+ (identifier) @local.definition.var)
+
+(local_declaration
+ (identifier) @local.definition.var
+ .
+ "=")