├── .gitattributes
├── .github
└── workflows
│ ├── ci.yml
│ └── generate-parser.yml
├── .gitignore
├── Cargo.toml
├── LICENSE
├── README.md
├── assets
└── highlight.png
├── binding.gyp
├── bindings
├── node
│ ├── binding.cc
│ └── index.js
└── rust
│ ├── build.rs
│ └── lib.rs
├── grammar.js
├── package-lock.json
├── package.json
├── queries
└── highlights.scm
├── src
├── grammar.json
├── node-types.json
├── parser.c
└── tree_sitter
│ └── parser.h
└── test
├── corpus
├── comments.txt
└── message.txt
└── highlight
└── basic.COMMIT_EDITMSG
/.gitattributes:
--------------------------------------------------------------------------------
1 | /src/**/* linguist-generated=true
2 | /bindings/**/* linguist-generated=true
3 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | bless:
7 | name: Bless
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - name: Checkout
12 | uses: actions/checkout@v3
13 |
14 | - name: Install Node
15 | uses: actions/setup-node@v3
16 | with:
17 | node-version: "16.x"
18 |
19 | - name: Cache npm dependencies
20 | uses: actions/cache@v3
21 | with:
22 | path: ~/.npm
23 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
24 | restore-keys: |
25 | ${{ runner.os }}-node-
26 |
27 | - name: Install npm dependencies
28 | run: npm ci
29 |
30 | - name: Ensure generated parser files are up to date
31 | run: npx tree-sitter generate
32 |
33 | - name: Run tree-sitter tests
34 | run: npx tree-sitter test
35 |
36 | - name: Check formatting
37 | run: npm run format-check
38 |
--------------------------------------------------------------------------------
/.github/workflows/generate-parser.yml:
--------------------------------------------------------------------------------
1 | # generates the parser with 'tree-sitter generate' if the parser is out of date
2 | name: Generate Parser
3 |
4 | on:
5 | push:
6 | branches:
7 | - main
8 |
9 | jobs:
10 | generate:
11 | name: Generate Parser
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v3
17 |
18 | - name: Install Node
19 | uses: actions/setup-node@v3
20 | with:
21 | node-version: "16.x"
22 |
23 | - name: Cache npm dependencies
24 | uses: actions/cache@v3
25 | with:
26 | path: ~/.npm
27 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28 | restore-keys: |
29 | ${{ runner.os }}-node-
30 |
31 | - name: Install npm dependencies
32 | run: npm ci
33 |
34 | - name: Generate parser files
35 | run: |
36 | npx tree-sitter generate
37 | npx tree-sitter build-wasm
38 |
39 | - name: Commit generated parser files
40 | uses: stefanzweifel/git-auto-commit-action@v4
41 | with:
42 | commit_message: Generate parser
43 | file_pattern: src
44 |
45 | - name: Checkout gh-pages branch to ./gh-pages
46 | uses: actions/checkout@v2
47 | with:
48 | ref: gh-pages
49 | path: ./gh-pages
50 |
51 | - run: mv *.wasm ./gh-pages
52 |
53 | - name: Commit generated WASM binding
54 | uses: stefanzweifel/git-auto-commit-action@v4
55 | with:
56 | commit_message: Generate WASM binding
57 | file_pattern: "*.wasm"
58 | repository: ./gh-pages
59 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /build/
3 | /tmp/
4 | /log.html
5 | /*.wasm
6 | /gh-pages/
7 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "tree-sitter-gitcommit"
3 | description = "gitcommit grammar for the tree-sitter parsing library"
4 | version = "0.0.1"
5 | keywords = ["incremental", "parsing", "gitcommit"]
6 | categories = ["parsing", "text-editors"]
7 | repository = "https://github.com/tree-sitter/tree-sitter-gitcommit"
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"
24 |
25 | [build-dependencies]
26 | cc = "1.0"
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Michael Davis
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 | # `tree-sitter-git-commit`
2 |
3 | [](https://github.com/the-mikedavis/tree-sitter-git-commit/actions/workflows/ci.yml)
4 |
5 | A [tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for git commit messages.
6 |
7 | ### Status
8 |
9 | Somewhat complete but needs testing and highlight queries.
10 |
11 | ### Example
12 |
13 | In the [Helix](https://github.com/helix-editor/helix) editor:
14 |
15 |
16 |
--------------------------------------------------------------------------------
/assets/highlight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-mikedavis/tree-sitter-git-commit/6f193a66e9aa872760823dff020960c6cedc37b3/assets/highlight.png
--------------------------------------------------------------------------------
/binding.gyp:
--------------------------------------------------------------------------------
1 | {
2 | "targets": [
3 | {
4 | "target_name": "tree_sitter_gitcommit_binding",
5 | "include_dirs": [
6 | "
3 | #include "nan.h"
4 |
5 | using namespace v8;
6 |
7 | extern "C" TSLanguage * tree_sitter_git_commit();
8 |
9 | namespace {
10 |
11 | NAN_METHOD(New) {}
12 |
13 | void Init(Local