From 258e3e1136b9fcd9af162005709f4d9c306ff151 Mon Sep 17 00:00:00 2001
From: Jean-Louis Fuchs <equal.hope10955@fastmail.com>
Date: Wed, 12 Feb 2025 16:46:50 +0100
Subject: [PATCH] feat: Add support for the Ink programming language (#12773)

---
 book/src/generated/lang-support.md |  1 +
 languages.toml                     | 14 ++++++++
 runtime/queries/ink/highlights.scm | 53 ++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 runtime/queries/ink/highlights.scm

diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 81aac6a6..c677b1d9 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -103,6 +103,7 @@
 | idris |  |  |  | `idris2-lsp` |
 | iex | ✓ |  |  |  |
 | ini | ✓ |  |  |  |
+| ink | ✓ |  |  |  |
 | inko | ✓ | ✓ | ✓ |  |
 | janet | ✓ |  |  |  |
 | java | ✓ | ✓ | ✓ | `jdtls` |
diff --git a/languages.toml b/languages.toml
index 8eabe75d..ecf23a9a 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4174,3 +4174,17 @@ language-servers = [ "yls" ]
 [[grammar]]
 name = "yara"
 source = { git = "https://github.com/egibs/tree-sitter-yara", rev = "eb3ede203275c38000177f72ec0f9965312806ef" }
+
+[[language]]
+name = "ink"
+scope = "source.ink"
+file-types = ["ink"]
+injection-regex = "ink"
+comment-token = "//"
+block-comment-tokens = { start = "/*", end = "*/"}
+indent = { tab-width = 4, unit = "\t" }
+soft-wrap = { enable = true }
+
+[[grammar]]
+name = "ink"
+source = { git = "https://github.com/rhizoome/tree-sitter-ink", rev = "8486e9b1627b0bc6b2deb9ee8102277a7c1281ac" }
diff --git a/runtime/queries/ink/highlights.scm b/runtime/queries/ink/highlights.scm
new file mode 100644
index 00000000..771721a1
--- /dev/null
+++ b/runtime/queries/ink/highlights.scm
@@ -0,0 +1,53 @@
+; tags and labels
+(label) @label
+(tag (identifier) @commment)
+(tag) @comment
+
+; values
+(identifier) @function
+(string) @string
+(boolean) @constant
+(number) @constant.numeric
+
+; headers
+(knot_header) @keyword
+(stitch_header) @keyword
+(function_header) @keyword
+
+; marks (ink)
+(option_mark) @keyword.directive
+(gather_mark) @type.builtin
+(glue) @type.builtin
+
+; calls
+(divert_or_thread) @function
+
+; operators
+(assignment) @operator
+
+; special marks/operators (ink)
+(arrow) @special
+(double_arrow) @special
+(back_arrow) @constant
+(dot) @special
+(mark_start) @special
+(mark_end) @special
+(hide_start) @special
+(hide_end) @special
+
+; declarations
+(var_line) @attribute
+(const_line) @constant
+(list_line) @type
+
+; comments
+(line_comment) @comment
+(block_comment) @comment
+
+; unparsed code
+(inline_block) @keyword
+(condition_block) @keyword
+(code_text) @keyword
+
+; support injection
+(program) @ui.text