aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author巢鹏 <chaopeng@chaopeng.me>2024-02-22 21:57:07 -0500
committerGitHub <noreply@github.com>2024-02-23 11:57:07 +0900
commita8d2b54e28b25cbea1a5fae312165f56674168de (patch)
tree1ffac806962b419cc692558f3a7fc910232b63ee
parentfeat(c-sharp): add enum member declaration highlight query (diff)
downloadnvim-treesitter-a8d2b54e28b25cbea1a5fae312165f56674168de.tar
nvim-treesitter-a8d2b54e28b25cbea1a5fae312165f56674168de.tar.gz
nvim-treesitter-a8d2b54e28b25cbea1a5fae312165f56674168de.tar.bz2
nvim-treesitter-a8d2b54e28b25cbea1a5fae312165f56674168de.tar.lz
nvim-treesitter-a8d2b54e28b25cbea1a5fae312165f56674168de.tar.xz
nvim-treesitter-a8d2b54e28b25cbea1a5fae312165f56674168de.tar.zst
nvim-treesitter-a8d2b54e28b25cbea1a5fae312165f56674168de.zip
feat: add fidl parser
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua9
-rw-r--r--queries/fidl/folds.scm6
-rw-r--r--queries/fidl/highlights.scm64
-rw-r--r--queries/fidl/injections.scm2
5 files changed, 84 insertions, 0 deletions
diff --git a/lockfile.json b/lockfile.json
index 8e909e250..5a2d278b5 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -164,6 +164,9 @@
"fennel": {
"revision": "9265a7d635d2f82a10738b9ad65ba8dd8bd4a84a"
},
+ "fidl": {
+ "revision": "0e1180bb126f280711a62f2a21e3609923fd8b0c"
+ },
"firrtl": {
"revision": "2b5adae629c8cba528c7b1e4aa67a8ae28934ea5"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 324529cad..bd647d595 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -535,6 +535,15 @@ list.fennel = {
maintainers = { "@alexmozaidze" },
}
+list.fidl = {
+ install_info = {
+ url = "https://github.com/google/tree-sitter-fidl",
+ files = { "src/parser.c" },
+ requires_generate_from_grammar = true,
+ },
+ maintainers = { "@chaopeng" },
+}
+
list.firrtl = {
install_info = {
url = "https://github.com/amaanq/tree-sitter-firrtl",
diff --git a/queries/fidl/folds.scm b/queries/fidl/folds.scm
new file mode 100644
index 000000000..f524c455b
--- /dev/null
+++ b/queries/fidl/folds.scm
@@ -0,0 +1,6 @@
+[
+ (layout_declaration)
+ (protocol_declaration)
+ (resource_declaration)
+ (service_declaration)
+] @fold
diff --git a/queries/fidl/highlights.scm b/queries/fidl/highlights.scm
new file mode 100644
index 000000000..ce7727010
--- /dev/null
+++ b/queries/fidl/highlights.scm
@@ -0,0 +1,64 @@
+[
+ "ajar"
+ "alias"
+ "as"
+ "bits"
+ "closed"
+ "compose"
+ "const"
+ "enum"
+ "error"
+ "flexible"
+ "library"
+ "open"
+ ; "optional" we did not specify a node for optional yet
+ "overlay"
+ "protocol"
+ "reserved"
+ "resource"
+ "service"
+ "strict"
+ "struct"
+ "table"
+ "type"
+ "union"
+ "using"
+] @keyword
+
+(primitives_type) @type.builtin
+
+(builtin_complex_type) @type.builtin
+
+(const_declaration
+ (identifier) @constant)
+
+[
+ "="
+ "|"
+ "&"
+ "->"
+] @operator
+
+(attribute
+ "@" @attribute
+ (identifier) @attribute)
+
+(string_literal) @string
+
+(numeric_literal) @number
+
+[
+ (true)
+ (false)
+] @boolean
+
+(comment) @comment
+
+[
+ "("
+ ")"
+ "<"
+ ">"
+ "{"
+ "}"
+] @punctuation.bracket
diff --git a/queries/fidl/injections.scm b/queries/fidl/injections.scm
new file mode 100644
index 000000000..2f0e58eb6
--- /dev/null
+++ b/queries/fidl/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))