aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYorick Peterse <git@yorickpeterse.com>2024-05-03 01:13:43 +0200
committerChristian Clason <c.clason@uni-graz.at>2024-05-03 11:32:15 +0200
commit7441b82fe558306b37c979a91c6c21d6bfae9a3c (patch)
treeb37cea907850a7d8e8c33f2f1fc9a238d504bf9c
parentbot(lockfile): update javascript, just, mlir, slint, templ (diff)
downloadnvim-treesitter-7441b82fe558306b37c979a91c6c21d6bfae9a3c.tar
nvim-treesitter-7441b82fe558306b37c979a91c6c21d6bfae9a3c.tar.gz
nvim-treesitter-7441b82fe558306b37c979a91c6c21d6bfae9a3c.tar.bz2
nvim-treesitter-7441b82fe558306b37c979a91c6c21d6bfae9a3c.tar.lz
nvim-treesitter-7441b82fe558306b37c979a91c6c21d6bfae9a3c.tar.xz
nvim-treesitter-7441b82fe558306b37c979a91c6c21d6bfae9a3c.tar.zst
nvim-treesitter-7441b82fe558306b37c979a91c6c21d6bfae9a3c.zip
feat(inko): add support for Inko
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/inko/folds.scm17
-rw-r--r--queries/inko/highlights.scm195
-rw-r--r--queries/inko/indents.scm40
-rw-r--r--queries/inko/injections.scm2
-rw-r--r--queries/inko/locals.scm57
8 files changed, 323 insertions, 0 deletions
diff --git a/README.md b/README.md
index c3f3afa3b..072583dc0 100644
--- a/README.md
+++ b/README.md
@@ -280,6 +280,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [hyprlang](https://github.com/luckasRanarison/tree-sitter-hyprlang) (maintained by @luckasRanarison)
- [x] [idl](https://github.com/cathaysia/tree-sitter-idl) (maintained by @cathaysa)
- [x] [ini](https://github.com/justinmk/tree-sitter-ini) (experimental, maintained by @theHamsta)
+- [x] [inko](https://github.com/inko-lang/tree-sitter-inko) (maintained by @yorickpeterse)
- [x] [ispc](https://github.com/fab4100/tree-sitter-ispc) (maintained by @fab4100)
- [x] [janet_simple](https://github.com/sogaiu/tree-sitter-janet-simple) (maintained by @sogaiu)
- [x] [java](https://github.com/tree-sitter/tree-sitter-java) (maintained by @p00f)
diff --git a/lockfile.json b/lockfile.json
index ad6002095..b59cb74e4 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -320,6 +320,9 @@
"ini": {
"revision": "bcb84a2d4bcd6f55b911c42deade75c8f90cb0c5"
},
+ "inko": {
+ "revision": "6983354c13a14bc621d7a3619f1790149e901187"
+ },
"ispc": {
"revision": "9b2f9aec2106b94b4e099fe75e73ebd8ae707c04"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index ad8cbf904..4a9d9695e 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -966,6 +966,14 @@ list.ini = {
experimental = true,
}
+list.inko = {
+ install_info = {
+ url = "https://github.com/inko-lang/tree-sitter-inko",
+ files = { "src/parser.c" },
+ },
+ maintainers = { "@yorickpeterse" },
+}
+
list.ispc = {
install_info = {
url = "https://github.com/fab4100/tree-sitter-ispc",
diff --git a/queries/inko/folds.scm b/queries/inko/folds.scm
new file mode 100644
index 000000000..b0fbc064e
--- /dev/null
+++ b/queries/inko/folds.scm
@@ -0,0 +1,17 @@
+[
+ (call)
+ (class)
+ (closure)
+ (define_case)
+ (define_constant)
+ (define_field)
+ (define_variable)
+ (external_function)
+ (if)
+ (import)+
+ (loop)
+ (match)
+ (method)
+ (trait)
+ (while)
+] @fold
diff --git a/queries/inko/highlights.scm b/queries/inko/highlights.scm
new file mode 100644
index 000000000..c19eb3a3a
--- /dev/null
+++ b/queries/inko/highlights.scm
@@ -0,0 +1,195 @@
+; Brackets and operators
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ ","
+ "->"
+ "."
+ ":"
+] @punctuation.delimiter
+
+[
+ "!="
+ "%"
+ "%="
+ "&"
+ "&="
+ "*"
+ "**"
+ "**="
+ "*="
+ "+"
+ "+="
+ "-"
+ "-="
+ "/"
+ "/="
+ "<"
+ "<<"
+ "<<="
+ "<="
+ "<="
+ "=="
+ ">"
+ ">="
+ ">="
+ ">>"
+ ">>="
+ ">>>"
+ ">>>="
+ "^"
+ "^="
+ "|"
+ "|="
+] @operator
+
+; Keywords
+[
+ "as"
+ "for"
+ "impl"
+ "let"
+ "mut"
+ "ref"
+ "uni"
+ "move"
+ "recover"
+] @keyword
+
+"fn" @keyword.function
+
+"import" @keyword.import
+
+[
+ "and"
+ "or"
+] @keyword.operator
+
+[
+ "class"
+ "trait"
+] @keyword.type
+
+[
+ "extern"
+ (modifier)
+ (visibility)
+] @keyword.modifier
+
+[
+ "loop"
+ "while"
+ (break)
+ (next)
+] @keyword.repeat
+
+"return" @keyword.return
+
+[
+ "throw"
+ "try"
+] @keyword.exception
+
+[
+ "case"
+ "else"
+ "if"
+ "match"
+] @keyword.conditional
+
+; Identifiers/variable references
+(identifier) @variable
+
+; Comments
+(line_comment) @comment @spell
+
+; Literals
+(self) @variable.builtin
+
+(nil) @constant.builtin
+
+[
+ (true)
+ (false)
+] @boolean
+
+(integer) @number
+
+(float) @number.float
+
+(string) @string
+
+(escape_sequence) @string.escape
+
+(interpolation
+ "${" @punctuation.special
+ "}" @punctuation.special) @none
+
+(constant) @constant
+
+; Patterns
+(integer_pattern) @number
+
+(string_pattern) @string
+
+(constant_pattern) @constant
+
+; Types
+(generic_type
+ name: _ @type)
+
+(type) @type
+
+; Imports
+(extern_import
+ path: _ @string)
+
+(import
+ (path
+ (identifier) @module))
+
+; Classes
+(class
+ name: _ @type)
+
+(define_field
+ name: _ @variable.member)
+
+; Traits
+(trait
+ name: _ @type)
+
+; Implementations
+(implement_trait
+ class: _ @type)
+
+(reopen_class
+ name: _ @type)
+
+(bound
+ name: _ @type)
+
+; Methods
+(method
+ name: _ @function)
+
+(external_function
+ name: _ @function)
+
+(argument
+ name: _ @variable.parameter)
+
+(named_argument
+ name: _ @variable.parameter)
+
+(call
+ name: _ @function)
+
+(field) @variable.member
diff --git a/queries/inko/indents.scm b/queries/inko/indents.scm
new file mode 100644
index 000000000..8a09edd97
--- /dev/null
+++ b/queries/inko/indents.scm
@@ -0,0 +1,40 @@
+[
+ (arguments)
+ (array)
+ (assign_field)
+ (assign_local)
+ (assign_receiver_field)
+ (binary)
+ (block)
+ (bounds)
+ (cast)
+ (class)
+ (class_pattern)
+ (compound_assign_field)
+ (compound_assign_local)
+ (compound_assign_receiver_field)
+ (define_constant)
+ (define_variable)
+ (grouped_expression)
+ (implement_trait)
+ (match)
+ (or_pattern)
+ (reopen_class)
+ (replace_field)
+ (replace_local)
+ (symbols)
+ (trait)
+ (tuple)
+ (tuple_pattern)
+ (type_arguments)
+] @indent.begin
+
+[
+ ")"
+ "]"
+ "}"
+] @indent.end @indent.branch
+
+(line_comment) @indent.auto
+
+(string) @indent.auto
diff --git a/queries/inko/injections.scm b/queries/inko/injections.scm
new file mode 100644
index 000000000..36849c873
--- /dev/null
+++ b/queries/inko/injections.scm
@@ -0,0 +1,2 @@
+((line_comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/queries/inko/locals.scm b/queries/inko/locals.scm
new file mode 100644
index 000000000..09450f525
--- /dev/null
+++ b/queries/inko/locals.scm
@@ -0,0 +1,57 @@
+[
+ (method)
+ (block)
+] @local.scope
+
+(method
+ name: _ @local.definition.method)
+
+(external_function
+ name: _ @local.definition.function)
+
+(argument
+ name: _ @local.definition.parameter)
+
+(define_variable
+ name: _ @local.definition.var)
+
+(define_constant
+ name: _ @local.definition.constant)
+
+(define_field
+ name: _ @local.definition.field)
+
+(named_argument
+ name: _ @local.definition.parameter)
+
+(class
+ modifier: (modifier
+ "enum")
+ name: _ @local.definition.enum)
+
+(class
+ modifier: (modifier
+ "enum")
+ body: (class_body
+ (define_case
+ name: _ @local.definition.field)))
+
+(class
+ name: _ @local.definition.type)
+
+(trait
+ name: _ @local.definition.type)
+
+(import
+ (symbols
+ [
+ (identifier)
+ (constant)
+ (self)
+ ] @local.definition.import))
+
+(identifier) @local.reference
+
+(field) @local.reference
+
+(constant) @local.reference