mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat: add Squirrel
This commit is contained in:
parent
ba4bce9bb7
commit
71be7c04d5
8 changed files with 480 additions and 0 deletions
|
|
@ -314,6 +314,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [solidity](https://github.com/JoranHonig/tree-sitter-solidity) (maintained by @amaanq)
|
||||
- [x] [sparql](https://github.com/BonaBeavis/tree-sitter-sparql) (maintained by @BonaBeavis)
|
||||
- [x] [sql](https://github.com/derekstride/tree-sitter-sql) (maintained by @derekstride)
|
||||
- [x] [squirrel](https://github.com/amaanq/tree-sitter-squirrel) (maintained by @amaanq)
|
||||
- [x] [starlark](https://github.com/amaanq/tree-sitter-starlark) (maintained by @amaanq)
|
||||
- [x] [supercollider](https://github.com/madskjeldgaard/tree-sitter-supercollider) (maintained by @madskjeldgaard)
|
||||
- [x] [surface](https://github.com/connorlay/tree-sitter-surface) (maintained by @connorlay)
|
||||
|
|
|
|||
|
|
@ -422,6 +422,9 @@
|
|||
"sql": {
|
||||
"revision": "1cb7c7a11015983f6d173847d5a3574f8e20107b"
|
||||
},
|
||||
"squirrel": {
|
||||
"revision": "518ab2feba8e14147009e788530b8ac88dfa9e73"
|
||||
},
|
||||
"starlark": {
|
||||
"revision": "8ad93a74c2a880bc16325affba3cc66c14bb2bde"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1329,6 +1329,14 @@ list.sql = {
|
|||
maintainers = { "@derekstride" },
|
||||
}
|
||||
|
||||
list.squirrel = {
|
||||
install_info = {
|
||||
url = "https://github.com/amaanq/tree-sitter-squirrel",
|
||||
files = { "src/parser.c", "src/scanner.c" },
|
||||
},
|
||||
maintainers = { "@amaanq" },
|
||||
}
|
||||
|
||||
list.starlark = {
|
||||
install_info = {
|
||||
url = "https://github.com/amaanq/tree-sitter-starlark",
|
||||
|
|
|
|||
27
queries/squirrel/folds.scm
Normal file
27
queries/squirrel/folds.scm
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
[
|
||||
(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
|
||||
307
queries/squirrel/highlights.scm
Normal file
307
queries/squirrel/highlights.scm
Normal file
|
|
@ -0,0 +1,307 @@
|
|||
; Keywords
|
||||
|
||||
[
|
||||
"class"
|
||||
"clone"
|
||||
"delete"
|
||||
"enum"
|
||||
"extends"
|
||||
"rawcall"
|
||||
"resume"
|
||||
"var"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"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"
|
||||
] @conditional
|
||||
|
||||
; Repeats
|
||||
|
||||
[
|
||||
"for"
|
||||
"foreach"
|
||||
"do"
|
||||
"while"
|
||||
"continue"
|
||||
] @repeat
|
||||
|
||||
; Exceptions
|
||||
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
"throw"
|
||||
] @exception
|
||||
|
||||
; Storageclasses
|
||||
|
||||
[
|
||||
"local"
|
||||
] @storageclass
|
||||
|
||||
; Qualifiers
|
||||
|
||||
[
|
||||
"static"
|
||||
"const"
|
||||
] @type.qualifier
|
||||
|
||||
; Variables
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
(local_declaration
|
||||
(identifier) @variable.local
|
||||
. "=")
|
||||
|
||||
|
||||
(global_variable) @variable.global
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#any-of? @variable.builtin "base" "this" "vargv"))
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameter
|
||||
. (identifier) @parameter)
|
||||
|
||||
; Properties (Slots)
|
||||
|
||||
(deref_expression
|
||||
"."
|
||||
. (identifier) @property)
|
||||
|
||||
(member_declaration
|
||||
(identifier) @property
|
||||
. "=")
|
||||
|
||||
((table_slot
|
||||
. (identifier) @property
|
||||
. ["=" ":"])
|
||||
(#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
|
||||
"::"? (_) @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
|
||||
"@" @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 Referece 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
|
||||
"?" @conditional.ternary
|
||||
":" @conditional.ternary)
|
||||
|
||||
; Literals
|
||||
|
||||
(string) @string
|
||||
|
||||
(verbatim_string) @string.special
|
||||
|
||||
(char) @character
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(integer) @number
|
||||
|
||||
(float) @float
|
||||
|
||||
(bool) @boolean
|
||||
|
||||
(null) @constant.builtin
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
58
queries/squirrel/indents.scm
Normal file
58
queries/squirrel/indents.scm
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
[
|
||||
(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
|
||||
|
||||
(
|
||||
(if_statement)
|
||||
(ERROR "else") @indent
|
||||
)
|
||||
|
||||
(if_statement
|
||||
condition: (_) @indent)
|
||||
|
||||
(if_statement
|
||||
consequence: (_)
|
||||
(else_statement) @indent)
|
||||
|
||||
(do_while_statement
|
||||
"do"
|
||||
(_) @indent)
|
||||
|
||||
(try_statement
|
||||
(_) @indent
|
||||
(catch_statement) @indent)
|
||||
|
||||
[ "{" "}" ] @branch
|
||||
|
||||
[ "(" ")" ] @branch
|
||||
|
||||
[ "[" "]" ] @branch
|
||||
|
||||
[
|
||||
"}"
|
||||
")"
|
||||
"]"
|
||||
] @indent_end
|
||||
|
||||
[
|
||||
(ERROR)
|
||||
(comment)
|
||||
|
||||
(string)
|
||||
(verbatim_string)
|
||||
] @auto
|
||||
9
queries/squirrel/injections.scm
Normal file
9
queries/squirrel/injections.scm
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(comment) @comment
|
||||
|
||||
((verbatim_string) @html
|
||||
(#lua-match? @html "^@\"<html")
|
||||
(#offset! @html 0 2 0 -1))
|
||||
|
||||
((verbatim_string) @html
|
||||
(#lua-match? @html "@\"<!DOCTYPE html>")
|
||||
(#offset! @html 0 2 0 -1))
|
||||
67
queries/squirrel/locals.scm
Normal file
67
queries/squirrel/locals.scm
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
; 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)
|
||||
] @scope
|
||||
|
||||
|
||||
; References
|
||||
|
||||
[
|
||||
(identifier)
|
||||
(global_variable)
|
||||
] @reference
|
||||
|
||||
; Definitions
|
||||
|
||||
(const_declaration
|
||||
. (identifier) @definition.constant)
|
||||
|
||||
(enum_declaration
|
||||
. (identifier) @definition.enum)
|
||||
|
||||
(member_declaration
|
||||
(identifier) @definition.field
|
||||
. "=")
|
||||
|
||||
(table_slot
|
||||
. (identifier) @definition.field
|
||||
. ["=" ":"])
|
||||
|
||||
((function_declaration
|
||||
. (identifier) @definition.function)
|
||||
(#not-has-ancestor? @definition.function member_declaration))
|
||||
|
||||
(member_declaration
|
||||
(function_declaration
|
||||
. (identifier) @definition.method))
|
||||
|
||||
(class_declaration
|
||||
. (identifier) @definition.type)
|
||||
|
||||
(var_statement
|
||||
"var" . (identifier) @definition.variable)
|
||||
|
||||
(local_declaration
|
||||
(identifier) @definition.variable
|
||||
. "=")
|
||||
Loading…
Add table
Add a link
Reference in a new issue