Commit
Author: Michael Davis [mcarsondavis@gmail.com]
Hash: 9809e32b533971ac2eaa9056783cbf5a7ca3ab4e
Timestamp: Sun, 26 Dec 2021 16:55:58 +0000 (2 years ago)

+12 -1 +/-1 browse
add readme section on grammar design
1diff --git a/README.md b/README.md
2index 6d86d55..c135929 100644
3--- a/README.md
4+++ b/README.md
5 @@ -2,7 +2,8 @@
6
7 [![CI](https://github.com/the-mikedavis/tree-sitter-git-diff/actions/workflows/ci.yml/badge.svg)](https://github.com/the-mikedavis/tree-sitter-git-diff/actions/workflows/ci.yml)
8
9- A [tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for `git diff`s.
10+ A [tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for
11+ `git diff`s.
12
13 ### Status
14
15 @@ -17,3 +18,13 @@ Highlighting a `.diff` file:
16 Injecting this grammar into [tree-sitter-git-commit](https://github.com/the-mikedavis/tree-sitter-git-commit) in a verbose commit (`git commit --verbose`):
17
18 <img src="assets/helix-commit-with-diff.png" width="500"/>
19+
20+ ### Design
21+
22+ This grammar is designed to be line-based: each line is parsed as its own
23+ top-level node in the `$.source`. It would probably be more useful to have
24+ the grammar parse each diff section (starting with `diff --git`) as its own
25+ subtree. As it is written now, though, the grammar can be injected into
26+ tree-sitter-git-commit without using combined injections, which are less
27+ supported among editors that use tree-sitter for highlighting. A future
28+ revision of this parser may upend this design decision.