docs: add README, LICENSE, and update package metadata
This commit is contained in:
@@ -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/*",
|
||||
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -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.
|
||||
113
README.md
Normal file
113
README.md
Normal file
@@ -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
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user