├── .github
└── workflows
│ ├── luarocks.yml
│ ├── release-please.yml
│ ├── tests.yml
│ └── tree-sitter-norg-meta.rockspec.template
├── .gitignore
├── CHANGELOG.md
├── Cargo.toml
├── LICENSE
├── README.md
├── binding.gyp
├── bindings
├── node
│ ├── binding.cc
│ └── index.js
└── rust
│ ├── build.rs
│ └── lib.rs
├── default.nix
├── flake.lock
├── flake.nix
├── grammar.js
├── package.json
├── queries
└── highlights.scm
├── src
├── grammar.json
├── node-types.json
├── parser.c
└── tree_sitter
│ └── parser.h
└── test
└── corpus
└── document.meta.txt
/.github/workflows/luarocks.yml:
--------------------------------------------------------------------------------
1 | name: Push to Luarocks
2 |
3 | on:
4 | push:
5 | release:
6 | types:
7 | - created
8 | tags:
9 | - '*'
10 | workflow_dispatch:
11 |
12 | jobs:
13 | luarocks-upload:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: actions/checkout@v4
17 | with:
18 | fetch-depth: 0 # Required to count the commits
19 | - name: Get Version
20 | run: echo "LUAROCKS_VERSION=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
21 | - name: Install C/C++ Compiler
22 | uses: rlalik/setup-cpp-compiler@master
23 | with:
24 | compiler: clang-latest
25 | - name: Install Lua
26 | uses: leso-kn/gh-actions-lua@master
27 | with:
28 | luaVersion: "5.1"
29 | - name: Install Luarocks
30 | uses: hishamhm/gh-actions-luarocks@master
31 | - name: Install `luarocks-build-treesitter-parser` Package
32 | run: |
33 | luarocks --verbose --local --lua-version=5.1 install luarocks-build-treesitter-parser
34 | - name: LuaRocks Upload
35 | uses: nvim-neorocks/luarocks-tag-release@v5
36 | env:
37 | LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
38 | with:
39 | name: tree-sitter-norg-meta
40 | version: ${{ env.LUAROCKS_VERSION }}
41 | labels: |
42 | neovim
43 | tree-sitter
44 | summary: Treesitter parser for Norg's `@document.meta` blocks.
45 | template: .github/workflows/tree-sitter-norg-meta.rockspec.template
46 |
--------------------------------------------------------------------------------
/.github/workflows/release-please.yml:
--------------------------------------------------------------------------------
1 | name: Release Please Automatic Semver
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | jobs:
9 | release:
10 | name: release
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: google-github-actions/release-please-action@v3
14 | with:
15 | release-type: rust
16 | package-name: tree-sitter-norg-meta
17 |
--------------------------------------------------------------------------------
/.github/workflows/tests.yml:
--------------------------------------------------------------------------------
1 | name: Parser tests
2 |
3 | on:
4 | push:
5 | branches:
6 | main
7 | pull_request:
8 |
9 | jobs:
10 | test_parser:
11 | strategy:
12 | fail-fast: false
13 | name: Testing
14 | runs-on: ubuntu-latest
15 | env:
16 | CC: clang
17 | steps:
18 | - name: Prepare tree-sitter
19 | uses: actions/checkout@v2
20 | with:
21 | repository: tree-sitter/tree-sitter
22 |
23 | - name: Prepare tree-sitter-norg-meta
24 | uses: actions/checkout@v2
25 | with:
26 | path: test/fixtures/grammars/norg_meta
27 |
28 | - name: Install tree-sitter CLI
29 | run: |
30 | cd test/fixtures/grammars/norg_meta
31 | npm install tree-sitter-cli
32 |
33 | - name: Run tests
34 | run: |
35 | cd test/fixtures/grammars/norg_meta
36 | ./node_modules/tree-sitter-cli/tree-sitter test
37 |
--------------------------------------------------------------------------------
/.github/workflows/tree-sitter-norg-meta.rockspec.template:
--------------------------------------------------------------------------------
1 | local git_ref = '$git_ref'
2 | local modrev = '$modrev'
3 | local specrev = '$specrev'
4 |
5 | local repo_url = '$repo_url'
6 |
7 | rockspec_format = '3.0'
8 | package = '$package'
9 | version = modrev ..'-'.. specrev
10 |
11 | description = {
12 | summary = '$summary',
13 | labels = $labels,
14 | homepage = '$homepage',
15 | $license
16 | }
17 |
18 | build_dependencies = {
19 | 'luarocks-build-treesitter-parser >= 1.3.0',
20 | }
21 |
22 | source = {
23 | url = repo_url .. '/archive/' .. git_ref .. '.zip',
24 | dir = '$repo_name-' .. '$archive_dir_suffix',
25 | }
26 |
27 | build = {
28 | type = "treesitter-parser",
29 | lang = "norg_meta",
30 | sources = { "src/parser.c" },
31 | }
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | build
3 | Cargo.lock
4 | package-lock.json
5 | yarn.lock
6 | *.log
7 | result
8 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 0.1.0 (2024-04-13)
4 |
5 |
6 | ### ⚠ BREAKING CHANGES
7 |
8 | * rewrite the parser to be more error prone
9 |
10 | ### Features
11 |
12 | * add luarocks support ([2673f0e](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/2673f0e57694347bc55bcaf319cb8e0a5e7a4c29))
13 | * basic delimiter support ([7268ed1](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/7268ed1e2571b21c0ec728b94f06984f7b9ba4be))
14 | * basic statement_group support ([90a73d1](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/90a73d19f7bdc678ef1e7d40936f1a60e7cd0888))
15 | * change some node names, add support for nested objects + arrays, write new tests ([7c9057c](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/7c9057ca182bfbcb52d5f9f2e4ea3da21b43c7fb))
16 | * crude trailing modifier support ([22ae523](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/22ae5236e5e349acd183d32f372ce7184dad1f40))
17 | * rewrite parser to make it more flexible ([35d9f25](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/35d9f25b440959eec1cf671632757357aa0425d9))
18 | * rewrite the parser to be more error prone ([0a00389](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/0a003896cf7bb42f52b5f188a90e42f8f3fbe57d))
19 | * veeery crude named delimiter support ([17741af](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/17741afcf6fd94b81399dab47ca9ece6456c9741))
20 |
21 |
22 | ### Bug Fixes
23 |
24 | * allow one-char values for pairs ([4687b53](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/4687b53e656b920cde6c0b9a7b9acf9a665cd838))
25 | * **ast:** don't make the separator a part of `key` ([bf5a57d](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/bf5a57dd74b22048aac72be2a71e13f1fc718e83))
26 | * broken parsing of values with special chars ([e93dcbc](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/e93dcbc56a472649547cfc288f10ae4a93ef8795))
27 | * incorrect detection of trailing modifiers ([#3](https://github.com/nvim-neorg/tree-sitter-norg-meta/issues/3)) ([323ef05](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/323ef0576e95d7c530546f6954362173fbaa56ac))
28 | * multi word descriptions ([ab7f37f](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/ab7f37f9186fdb49a9f9d764079b24db8556830c))
29 | * remove hard-coded space groups ([99b1ffc](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/99b1ffcc5d1f0fb9a0edb382980ddf21e0f0d546))
30 | * repo links ([8d9792b](https://github.com/nvim-neorg/tree-sitter-norg-meta/commit/8d9792bf94a22e4a1d0fdf6de52e099c471bf26e))
31 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "tree-sitter-norg-meta"
3 | description = "norg-meta grammar for the tree-sitter parsing library"
4 | version = "0.1.0"
5 | keywords = ["incremental", "parsing", "norg-meta"]
6 | categories = ["parsing", "text-editors"]
7 | repository = "https://github.com/tree-sitter/tree-sitter-norg-meta"
8 | edition = "2018"
9 | license = "MIT"
10 |
11 | build = "bindings/rust/build.rs"
12 | include = [
13 | "bindings/rust/*",
14 | "grammar.js",
15 | "queries/*",
16 | "src/*",
17 | ]
18 |
19 | [lib]
20 | path = "bindings/rust/lib.rs"
21 |
22 | [dependencies]
23 | tree-sitter = "~0.20.0"
24 |
25 | [build-dependencies]
26 | cc = "1.0"
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Neorg
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NFF Metadata TreeSitter Parser
2 |
3 |
4 |
5 | A TreeSitter grammar for [Neorg's](https://github.com/nvim-neorg/neorg) `document.meta` format.
6 |
7 | ## Available Commands
8 | | Command | Result |
9 | |-------------|-------------------------------------------------------------------------------------|
10 | | `yarn` | installs needed dependencies (only do if you don't have `tree-sitter` in your path) |
11 | | `yarn gen` | `tree-sitter generate && node-gyp build` |
12 | | `yarn test` | `tree-sitter test` |
13 |
14 | - `npm` can be used instead of `yarn`
15 | - When `yarn` is used with no args then it's replaced with `node install`
16 |
17 | # :heart: Contribution
18 | If you know a thing or two about TreeSitter and would like to support us by contributing then please do!
19 | If you have any questions you can ask away in the Github issues or on our discord! The specification can be found in the
20 | `docs/` directory in the [Neorg Repo](https://github.com/nvim-neorg/neorg).
21 |
--------------------------------------------------------------------------------
/binding.gyp:
--------------------------------------------------------------------------------
1 | {
2 | "targets": [
3 | {
4 | "target_name": "tree_sitter_norg_meta_binding",
5 | "include_dirs": [
6 | "
3 | #include "nan.h"
4 |
5 | using namespace v8;
6 |
7 | extern "C" TSLanguage * tree_sitter_norg_meta();
8 |
9 | namespace {
10 |
11 | NAN_METHOD(New) {}
12 |
13 | void Init(Local