mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat: add Hare
This commit is contained in:
parent
98d63d0da4
commit
207a86e4c9
8 changed files with 379 additions and 0 deletions
|
|
@ -235,6 +235,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [gowork](https://github.com/omertuc/tree-sitter-go-work) (maintained by @omertuc)
|
||||
- [x] [graphql](https://github.com/bkegley/tree-sitter-graphql) (maintained by @bkegley)
|
||||
- [ ] [hack](https://github.com/slackhq/tree-sitter-hack)
|
||||
- [x] [hare](https://github.com/amaanq/tree-sitter-hare) (maintained by @amaanq)
|
||||
- [ ] [haskell](https://github.com/tree-sitter/tree-sitter-haskell)
|
||||
- [x] [hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann)
|
||||
- [x] [heex](https://github.com/connorlay/tree-sitter-heex) (maintained by @connorlay)
|
||||
|
|
|
|||
|
|
@ -185,6 +185,9 @@
|
|||
"hack": {
|
||||
"revision": "b7bd6928532ada34dddb1dece4a158ab62c6e783"
|
||||
},
|
||||
"hare": {
|
||||
"revision": "f0a9e6207a8c84bbd11143c8eb0c6cf70dc6d8b4"
|
||||
},
|
||||
"haskell": {
|
||||
"revision": "0da7f826e85b3e589e217adf69a6fd89ee4301b9"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -628,6 +628,14 @@ list.hack = {
|
|||
},
|
||||
}
|
||||
|
||||
list.hare = {
|
||||
install_info = {
|
||||
url = "https://github.com/amaanq/tree-sitter-hare",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
maintainers = { "@amaanq" },
|
||||
}
|
||||
|
||||
list.haskell = {
|
||||
install_info = {
|
||||
url = "https://github.com/tree-sitter/tree-sitter-haskell",
|
||||
|
|
|
|||
21
queries/hare/folds.scm
Normal file
21
queries/hare/folds.scm
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[
|
||||
(imports)
|
||||
|
||||
(function_declaration)
|
||||
(enum_type)
|
||||
(struct_type)
|
||||
(tuple_type)
|
||||
(union_type)
|
||||
|
||||
(block)
|
||||
(if_statement)
|
||||
(for_statement)
|
||||
(call_expression)
|
||||
(switch_expression)
|
||||
(match_expression)
|
||||
(case)
|
||||
|
||||
(array_literal)
|
||||
(struct_literal)
|
||||
(tuple_literal)
|
||||
] @fold
|
||||
255
queries/hare/highlights.scm
Normal file
255
queries/hare/highlights.scm
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
; Variables
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
; Types
|
||||
|
||||
(type) @type
|
||||
|
||||
(scoped_type_identifier
|
||||
(identifier) . (identifier) @type)
|
||||
|
||||
(struct_literal
|
||||
. (identifier) @type)
|
||||
|
||||
(builtin_type) @type.builtin
|
||||
|
||||
; Constants
|
||||
|
||||
((identifier) @constant
|
||||
(#lua-match? @constant "^[A-Z_]+$"))
|
||||
|
||||
; Includes
|
||||
|
||||
[
|
||||
"use"
|
||||
] @include
|
||||
|
||||
(use_statement
|
||||
(scoped_type_identifier
|
||||
(identifier) @namespace))
|
||||
(use_statement
|
||||
(identifier) @namespace "{")
|
||||
(use_statement
|
||||
. (identifier) @namespace .)
|
||||
|
||||
((scoped_type_identifier
|
||||
path: (_) @namespace)
|
||||
(#set! "priority" 105))
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"def"
|
||||
"enum"
|
||||
"export"
|
||||
"let"
|
||||
"struct"
|
||||
"type"
|
||||
"union"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"fn"
|
||||
] @keyword.function
|
||||
|
||||
[
|
||||
"defer"
|
||||
"yield"
|
||||
"return"
|
||||
] @keyword.return
|
||||
|
||||
[
|
||||
"as"
|
||||
"is"
|
||||
] @keyword.operator
|
||||
|
||||
; Typedefs
|
||||
|
||||
(type_declaration
|
||||
"type" (identifier) @type.definition . "=")
|
||||
|
||||
; Qualifiers
|
||||
|
||||
[
|
||||
"const"
|
||||
"static"
|
||||
"nullable"
|
||||
] @type.qualifier
|
||||
|
||||
; Attributes
|
||||
|
||||
[
|
||||
"@fini"
|
||||
"@init"
|
||||
"@test"
|
||||
"@noreturn"
|
||||
"@packed"
|
||||
(declaration_attribute)
|
||||
] @attribute
|
||||
|
||||
; Labels
|
||||
|
||||
((label) @label
|
||||
(#set! "priority" 105))
|
||||
|
||||
; Functions
|
||||
|
||||
(function_declaration
|
||||
"fn" . (identifier) @function)
|
||||
|
||||
(call_expression
|
||||
. (identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
. (scoped_type_identifier
|
||||
. (identifier) . "::" . (identifier) @method.call))
|
||||
|
||||
((call_expression
|
||||
. (identifier) @function.builtin)
|
||||
(#any-of? @function.builtin "align" "assert" "free" "len" "offset" "size"))
|
||||
|
||||
(size_expression
|
||||
"size" @function.builtin)
|
||||
|
||||
((function_declaration
|
||||
"fn" . (identifier) @constructor)
|
||||
(#eq? @constructor "init"))
|
||||
|
||||
((call_expression
|
||||
. (identifier) @constructor)
|
||||
(#eq? @constructor "init"))
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameter
|
||||
(_) @parameter . ":")
|
||||
|
||||
; Fields
|
||||
|
||||
((member_expression
|
||||
"." (_) @field)
|
||||
(#set! "priority" 105))
|
||||
|
||||
(field
|
||||
. (identifier) @field)
|
||||
|
||||
(field_assignment
|
||||
. (identifier) @field)
|
||||
|
||||
; Repeats
|
||||
|
||||
[
|
||||
"for"
|
||||
] @repeat
|
||||
|
||||
; Conditionals
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"break"
|
||||
"switch"
|
||||
"match"
|
||||
"case"
|
||||
] @conditional
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"||"
|
||||
"&&"
|
||||
"^^"
|
||||
"|"
|
||||
"&"
|
||||
"^"
|
||||
"=="
|
||||
"!="
|
||||
">"
|
||||
">="
|
||||
"<="
|
||||
"<"
|
||||
"<<"
|
||||
">>"
|
||||
"~"
|
||||
"!"
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"<<="
|
||||
">>="
|
||||
"|="
|
||||
"&="
|
||||
"^="
|
||||
"||="
|
||||
"&&="
|
||||
"^^="
|
||||
"="
|
||||
"?"
|
||||
] @operator
|
||||
|
||||
; Punctuation
|
||||
|
||||
[ "{" "}" ] @punctuation.bracket
|
||||
|
||||
[ "[" "]" ] @punctuation.bracket
|
||||
|
||||
[ "(" ")" ] @punctuation.bracket
|
||||
|
||||
[
|
||||
".."
|
||||
"..."
|
||||
"_"
|
||||
] @punctuation.special
|
||||
|
||||
(pointer_type "*" @punctuation.special)
|
||||
|
||||
(slice_type "*" @punctuation.special)
|
||||
|
||||
(error_type "!" @punctuation.special)
|
||||
|
||||
[
|
||||
","
|
||||
"."
|
||||
":"
|
||||
";"
|
||||
"::"
|
||||
"=>"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Literals
|
||||
|
||||
[
|
||||
(string)
|
||||
(raw_string)
|
||||
] @string
|
||||
|
||||
(rune) @character
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(number) @number
|
||||
|
||||
(float) @float
|
||||
|
||||
(boolean) @boolean
|
||||
|
||||
[
|
||||
(void)
|
||||
(null)
|
||||
] @constant.builtin
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment @spell
|
||||
|
||||
; Errors
|
||||
|
||||
(ERROR) @error
|
||||
36
queries/hare/indents.scm
Normal file
36
queries/hare/indents.scm
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
[
|
||||
(enum_type)
|
||||
(struct_type)
|
||||
(tuple_type)
|
||||
(union_type)
|
||||
|
||||
(block)
|
||||
(for_statement)
|
||||
(call_expression)
|
||||
(case)
|
||||
|
||||
(array_literal)
|
||||
(struct_literal)
|
||||
(tuple_literal)
|
||||
] @indent
|
||||
|
||||
(if_statement
|
||||
("(" condition: (_) ")") @indent)
|
||||
|
||||
[
|
||||
"}"
|
||||
"]"
|
||||
")"
|
||||
] @indent_end
|
||||
|
||||
[ "{" "}" ] @branch
|
||||
|
||||
[ "[" "]" ] @branch
|
||||
|
||||
[ "(" ")" ] @branch
|
||||
|
||||
[
|
||||
(ERROR)
|
||||
(comment)
|
||||
(concatenated_string)
|
||||
] @auto
|
||||
8
queries/hare/injections.scm
Normal file
8
queries/hare/injections.scm
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(comment) @comment
|
||||
|
||||
((call_expression
|
||||
. (_) @_fnname
|
||||
. "("
|
||||
. (_ [(string_content) (raw_string_content)] @regex)
|
||||
. ")")
|
||||
(#any-of? @_fnname "compile" "regex::compile"))
|
||||
47
queries/hare/locals.scm
Normal file
47
queries/hare/locals.scm
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
; Scopes
|
||||
|
||||
[
|
||||
(module)
|
||||
(function_declaration)
|
||||
(if_statement)
|
||||
(for_statement)
|
||||
(match_expression)
|
||||
(switch_expression)
|
||||
] @scope
|
||||
|
||||
; References
|
||||
|
||||
[
|
||||
(identifier)
|
||||
(scoped_type_identifier)
|
||||
] @reference
|
||||
|
||||
; Definitions
|
||||
|
||||
(global_binding
|
||||
(identifier) @definition.constant . ":" (_))
|
||||
|
||||
(const_declaration
|
||||
"const" (identifier) @definition.constant . "=")
|
||||
|
||||
(field
|
||||
. (identifier) @definition.field)
|
||||
|
||||
(field_assignment
|
||||
. (identifier) @definition.field)
|
||||
|
||||
(function_declaration
|
||||
"fn" . (identifier) @definition.function)
|
||||
|
||||
(parameter
|
||||
(_) @definition.parameter . ":")
|
||||
|
||||
(type_declaration
|
||||
"type" (identifier) @definition.type . "=")
|
||||
|
||||
(type_declaration
|
||||
"type" (identifier) @definition.enum . "=" (enum_type))
|
||||
|
||||
(let_declaration
|
||||
"let" . (identifier) @definition.variable ","?)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue