From 7c935d6bd5ecb36e7c6cf6678e1eaa38b85111f3 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 21 Aug 2023 04:29:38 -0400 Subject: feat: add Forth --- README.md | 1 + lockfile.json | 3 +++ lua/nvim-treesitter/parsers.lua | 8 ++++++++ queries/forth/folds.scm | 1 + queries/forth/highlights.scm | 21 +++++++++++++++++++++ queries/forth/indents.scm | 3 +++ queries/forth/injections.scm | 2 ++ queries/forth/locals.scm | 3 +++ 8 files changed, 42 insertions(+) create mode 100644 queries/forth/folds.scm create mode 100644 queries/forth/highlights.scm create mode 100644 queries/forth/indents.scm create mode 100644 queries/forth/injections.scm create mode 100644 queries/forth/locals.scm diff --git a/README.md b/README.md index 3c3f11751..c701aeed7 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [firrtl](https://github.com/amaanq/tree-sitter-firrtl) (maintained by @amaanq) - [x] [fish](https://github.com/ram02z/tree-sitter-fish) (maintained by @ram02z) - [x] [foam](https://github.com/FoamScience/tree-sitter-foam) (experimental, maintained by @FoamScience) +- [x] [forth](https://github.com/AlexanderBrevig/tree-sitter-forth) (maintained by @amaanq) - [x] [fortran](https://github.com/stadelmanma/tree-sitter-fortran) (maintained by @amaanq) - [x] [fsh](https://github.com/mgramigna/tree-sitter-fsh) (maintained by @mgramigna) - [x] [func](https://github.com/amaanq/tree-sitter-func) (maintained by @amaanq) diff --git a/lockfile.json b/lockfile.json index bc090b73d..8743a10eb 100644 --- a/lockfile.json +++ b/lockfile.json @@ -146,6 +146,9 @@ "foam": { "revision": "09e03445f49290450589c5d293610ab39434e3e4" }, + "forth": { + "revision": "304ed77beb113e37af38b20ff14e3c37bf350d10" + }, "fortran": { "revision": "6828cf3629addb1706bdbbd33491e95f12b7042c" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index a4150c8eb..bd956ea9d 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -487,6 +487,14 @@ list.foam = { experimental = true, } +list.forth = { + install_info = { + url = "https://github.com/AlexanderBrevig/tree-sitter-forth", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + list.fortran = { install_info = { url = "https://github.com/stadelmanma/tree-sitter-fortran", diff --git a/queries/forth/folds.scm b/queries/forth/folds.scm new file mode 100644 index 000000000..443abb30d --- /dev/null +++ b/queries/forth/folds.scm @@ -0,0 +1 @@ +(word_definition) @fold diff --git a/queries/forth/highlights.scm b/queries/forth/highlights.scm new file mode 100644 index 000000000..e8c53e9ce --- /dev/null +++ b/queries/forth/highlights.scm @@ -0,0 +1,21 @@ +(core) @function + +(operator) @operator + +(word) @variable + +((word) @constant + (#lua-match? @constant "^[A-Z_]+$")) + +(number) @number + +(string) @string + +[ + (start_definition) + (end_definition) +] @punctuation.delimiter + +(comment) @comment + +(ERROR) @error diff --git a/queries/forth/indents.scm b/queries/forth/indents.scm new file mode 100644 index 000000000..067755433 --- /dev/null +++ b/queries/forth/indents.scm @@ -0,0 +1,3 @@ +(word_definition) @indent.begin + +(end_definition) @indent.end @indent.branch diff --git a/queries/forth/injections.scm b/queries/forth/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/queries/forth/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/queries/forth/locals.scm b/queries/forth/locals.scm new file mode 100644 index 000000000..3a5e191d2 --- /dev/null +++ b/queries/forth/locals.scm @@ -0,0 +1,3 @@ +(word) @reference + +(word_definition) @scope -- cgit v1.3