From 6cf93175bf011ca899e494376838ae147870a1eb Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 23 Jan 2023 03:00:32 -0500 Subject: [PATCH] feat: add capnp (#4203) --- README.md | 1 + lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 9 +++ queries/capnp/highlights.scm | 124 ++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 queries/capnp/highlights.scm diff --git a/README.md b/README.md index a85ad44ce..852f2a921 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [bibtex](https://github.com/latex-lsp/tree-sitter-bibtex) (maintained by @theHamsta, @clason) - [x] [blueprint](https://gitlab.com/gabmus/tree-sitter-blueprint.git) (experimental, maintained by @gabmus) - [x] [c](https://github.com/tree-sitter/tree-sitter-c) (maintained by @vigoux) +- [x] [capnp](https://github.com/amaanq/tree-sitter-capnp) (experimental, maintained by @amaanq) - [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @Luxed) - [x] [clojure](https://github.com/sogaiu/tree-sitter-clojure) (maintained by @sogaiu) - [x] [cmake](https://github.com/uyha/tree-sitter-cmake) (maintained by @uyha) diff --git a/lockfile.json b/lockfile.json index b57597cc8..d68dd0fb5 100644 --- a/lockfile.json +++ b/lockfile.json @@ -29,6 +29,9 @@ "c": { "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, + "capnp": { + "revision": "fda654c12f29ec70309d9573bc0af16b7124384e" + }, "c_sharp": { "revision": "a29bac0681802139710b4d3875540901504d15cb" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index e4d1da4d9..583466b99 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1195,6 +1195,15 @@ list.astro = { maintainers = { "@virchau13" }, } +list.capnp = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-capnp", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, + experimental = true, +} + list.wgsl = { install_info = { url = "https://github.com/szebniok/tree-sitter-wgsl", diff --git a/queries/capnp/highlights.scm b/queries/capnp/highlights.scm new file mode 100644 index 000000000..0f6815aa6 --- /dev/null +++ b/queries/capnp/highlights.scm @@ -0,0 +1,124 @@ +; Preproc (?) + +(unique_id) @preproc + +; Includes + +[ + "import" + "$import" + "embed" +] @include + +(import_path) @string + +; Types + +(primitive_type) @type.builtin + +[ + "annotation" + "enum" + "group" + "interface" + "List" + "struct" + "union" +] @type.builtin + +; Typedefs + +(type_definition) @type.definition + +; Labels (@number, @number!) + +(field_version) @label + +; Methods + +(method_identifier) @method + +; Fields + +(field_identifier) @field + +; Parameters + +(param_identifier) @parameter +(return_identifier) @parameter + +; Variables + +(identifier) @variable + +; Constants + +(const_identifier) @constant +(enum_member) @constant + +; Types + +(enum_identifier) @type +(extend_type) @type +(field_type) @type +(generic_identifier) @type +(type_identifier) @type + +; Attributes + +(attribute) @attribute +(annotation_identifier) @attribute + +; Operators + +[ + ; @ ! - + "=" +] @operator + +; Keywords + +[ + "extends" + "namespace" + "using" +] @keyword + +; Literals + +(string_literal) @string + +(data_string) @string.special +(namespace) @string.special + +(number) @number + +(float) @float + +(boolean) @boolean + +; Misc + +[ + "const" +] @type.qualifier + +[ + "*" +] @punctuation.special + +["{" "}"] @punctuation.bracket + +["(" ")"] @punctuation.bracket + +["[" "]"] @punctuation.bracket + +[ + "," + ";" + "->" +] @punctuation.delimiter + +; Comments + +(comment) @comment @spell