From d1e6f6a4cbf082cb76774918d0c6fae2e33b12ff Mon Sep 17 00:00:00 2001 From: vikingowl Date: Fri, 27 Mar 2026 10:36:14 +0100 Subject: [PATCH] docs: add README, LICENSE, and update package metadata --- Cargo.toml | 1 + LICENSE | 21 ++++++++++ README.md | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 9 ++-- 4 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 LICENSE create mode 100644 README.md diff --git a/Cargo.toml b/Cargo.toml index 01bfdb8..fedb683 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ license = "MIT" edition = "2021" rust-version = "1.65" keywords = ["parser", "tree-sitter", "rune"] +categories = ["parsing", "text-editors"] include = [ "bindings/rust/*", "queries/*", diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..91b411e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 tree-sitter-rune contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..19eee8c --- /dev/null +++ b/README.md @@ -0,0 +1,113 @@ +# tree-sitter-rune + +[Rune](https://rune-rs.github.io/) grammar for [tree-sitter](https://tree-sitter.github.io/). + +Provides syntax highlighting, indentation, code folding, and scope tracking for `.rn` files. + +## Supported Syntax + +- Functions (`fn`, `pub fn`, `async fn`) +- Structs (named, tuple, unit) +- Enums (unit, tuple, struct variants) +- Modules and imports (`mod`, `use`) +- Control flow (`if`/`else`, `match` with guards, `loop`, `while`, `for`) +- Pattern matching (tuple, struct, enum, or-patterns, wildcards, rest) +- Closures (sync and async) +- Template literals (`` `hello ${name}` ``) +- Object literals (`#{ key: value }`) +- Generators (`yield`) +- Async/await and `select` blocks +- `is` / `is not` type checking +- Macro invocations (`println!()`) + +## Installation + +### Neovim (nvim-treesitter) + +Add a custom parser in your Neovim config: + +```lua +local parser_config = require("nvim-treesitter.parsers").get_parser_configs() +parser_config.rune = { + install_info = { + url = "https://github.com/TODO/tree-sitter-rune", + files = { "src/parser.c", "src/scanner.c" }, + branch = "main", + }, + filetype = "rune", +} + +vim.filetype.add({ + extension = { + rn = "rune", + }, +}) +``` + +Then run `:TSInstall rune`. + +### Formatter Integration + +Rune ships a built-in formatter (`rune fmt`) since v0.13. To integrate with [conform.nvim](https://github.com/stevearc/conform.nvim): + +```lua +require("conform").setup({ + formatters_by_ft = { + rune = { "rune_fmt" }, + }, + formatters = { + rune_fmt = { + command = "rune", + args = { "fmt", "$FILENAME" }, + stdin = false, + }, + }, +}) +``` + +## Development + +### Prerequisites + +- [Node.js](https://nodejs.org/) (v18+) +- [tree-sitter CLI](https://tree-sitter.github.io/) (`cargo install tree-sitter-cli` or `npm i -g tree-sitter-cli`) +- C compiler + +### Build + +```bash +npm install +npx tree-sitter generate +``` + +### Test + +```bash +npx tree-sitter test +``` + +### Parse a file + +```bash +npx tree-sitter parse path/to/file.rn +``` + +### Preview highlighting + +```bash +npx tree-sitter highlight path/to/file.rn +``` + +## Query Files + +| File | Purpose | +|---|---| +| `queries/highlights.scm` | Syntax highlighting | +| `queries/indents.scm` | Auto-indentation | +| `queries/folds.scm` | Code folding | +| `queries/locals.scm` | Scope/variable tracking | +| `queries/tags.scm` | Code navigation (definitions, references) | + +## License + +MIT diff --git a/package.json b/package.json index 462da31..0cb895b 100644 --- a/package.json +++ b/package.json @@ -11,11 +11,12 @@ ], "files": [ "grammar.js", + "tree-sitter.json", "binding.gyp", - "prebuilds/", - "queries/", - "src/", - "bindings/node" + "prebuilds/**", + "queries/*", + "src/**", + "bindings/node/*" ], "dependencies": { "node-addon-api": "^8.2.2",