Unnamed repository; edit this file 'description' to name the repository.
add highlighting for nearley (#14482)
evie 5 months ago
parent 81b4a2c · commit 6fffaf6
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml11
-rw-r--r--runtime/queries/nearley/highlights.scm43
-rw-r--r--runtime/queries/nearley/injections.scm2
-rw-r--r--runtime/queries/nearley/rainbows.scm3
5 files changed, 60 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 8fa9aed2..67cd39c1 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -174,6 +174,7 @@
| move | ✓ | | | | | |
| msbuild | ✓ | | ✓ | | | |
| nasm | ✓ | ✓ | | | | `asm-lsp` |
+| nearley | ✓ | | | | ✓ | |
| nestedtext | ✓ | ✓ | ✓ | | | |
| nginx | ✓ | | | | | |
| nickel | ✓ | | ✓ | | | `nls` |
diff --git a/languages.toml b/languages.toml
index f46e8c43..1ebd15ac 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4876,3 +4876,14 @@ indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "slisp"
source = { git = "https://github.com/xenogenics/tree-sitter-slisp", rev = "29f9c6707ce9dfc2fc915d175ec720b207f179f3" }
+
+[[language]]
+name = "nearley"
+scope = "source.nearley"
+file-types = ["ne"]
+comment-token = "#"
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "nearley"
+source = { git = "https://github.com/mi2ebi/tree-sitter-nearley", rev = "12d01113e194c8e83f6341aab8c2a5f21db9cac9" }
diff --git a/runtime/queries/nearley/highlights.scm b/runtime/queries/nearley/highlights.scm
new file mode 100644
index 00000000..7cc0b6e4
--- /dev/null
+++ b/runtime/queries/nearley/highlights.scm
@@ -0,0 +1,43 @@
+
+(comment) @comment.line
+
+(string) @string
+(string "i" @keyword.modifier)
+
+(identifier) @variable.other
+(rule_name (identifier) @function)
+(rule (generic (identifier) @function))
+
+(directive_name) @keyword.directive
+(directive_value (identifier) @constant)
+(directive_value (string) @string)
+
+(token) @constant
+
+(generic
+ "<" @punctuation.bracket
+ (identifier) @type.parameter
+ ">" @punctuation.bracket
+)
+
+(group "(" @punctuation.bracket ")" @punctuation.bracket)
+
+(charset) @string.regexp
+(wildcard) @keyword
+
+(quantifier) @function.builtin
+
+(macro_name
+ "[" @punctuation.bracket
+ (identifier) @variable.parameter
+ "]" @punctuation.bracket
+)
+(macro_arg) @variable.parameter
+
+(rule "->" @operator)
+(rule_body "|" @operator)
+
+(cont_block "@{%" @keyword.directive "%}" @keyword.directive)
+(cont_inline "{%" @keyword.directive "%}" @keyword.directive)
+
+(ifdef) @keyword.directive
diff --git a/runtime/queries/nearley/injections.scm b/runtime/queries/nearley/injections.scm
new file mode 100644
index 00000000..d8168304
--- /dev/null
+++ b/runtime/queries/nearley/injections.scm
@@ -0,0 +1,2 @@
+((cont) @injection.content
+ (#set! injection.language "javascript"))
diff --git a/runtime/queries/nearley/rainbows.scm b/runtime/queries/nearley/rainbows.scm
new file mode 100644
index 00000000..5de4f8e1
--- /dev/null
+++ b/runtime/queries/nearley/rainbows.scm
@@ -0,0 +1,3 @@
+((group) @rainbow.scope)
+
+["(" ")"] @rainbow.bracket