slackhq / tree-sitter-hack

Hack grammar for tree-sitter
MIT License
33 stars 15 forks source link

Mark treesitter files as generated #45

Closed 4e554c4c closed 2 years ago

4e554c4c commented 2 years ago

The treesitter files are autogenerated and are constantly changing, leading to hundreds of thousands of lines in code review. They are currently marked as "vendored" however this is for code which was manually written but automatically checked in. The generated attribute should be used instead so that changes to the files do not appear in code review.

see https://github.com/github/linguist/blob/master/docs/overrides.md and https://git-scm.com/docs/gitattributes for more info.

test plan: modify grammar.js, run treesitter generate and look at diff:

$ git diff
diff --git a/grammar.js b/grammar.js
index fc3f9d5..980e927 100644
--- a/grammar.js
+++ b/grammar.js
@@ -117,7 +117,7 @@ const rules = {
       $.unset_statement,

       $.use_statement,
-      $.if_statement,
+      //$.if_statement,
       $.while_statement,
       $.do_statement,
       $.for_statement,
diff --git a/src/grammar.json b/src/grammar.json
index 2f7db16..e79c578 100644
Binary files a/src/grammar.json and b/src/grammar.json differ
diff --git a/src/node-types.json b/src/node-types.json
index 4d0bac2..bc9e906 100644
Binary files a/src/node-types.json and b/src/node-types.json differ
diff --git a/src/parser.c b/src/parser.c
index aceb5de..9e41958 100644
Binary files a/src/parser.c and b/src/parser.c differ
diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h
index cbbc7b4..2b14ac1 100644
Binary files a/src/tree_sitter/parser.h and b/src/tree_sitter/parser.h differ

Requirements (place an x in each [ ])

frankeld commented 2 years ago

@4e554c4c Thanks for the contribution! Happy to update to linguist-generated. What's the motivation for removing the binary attribute (rather than keeping them as /src/grammar.json binary linguist-generated)? Although they are not technically binaries, labeling them as binaries prevents autogenerated noise from clogging diffs. Do you find it more useful to see those changes?

4e554c4c commented 2 years ago

@frankeld Oh I didn't think about git diff. I'm pretty sure that the !diff attribute would fix this, let me test it out

frankeld commented 2 years ago

-diff will work, as binary is just a macro for -diff -merge -text

4e554c4c commented 2 years ago

sounds good, mind leaving a review?