firrtl-spec
firrtl-spec copied to clipboard
Linguist Support, TextMate Grammar Support
FIRRTL has enough usage (O(100) repositories) that we can get it in as a supported language by Linguist (GitHub's source code identification/highlighting repository). This requires two things as far as I can sort out:
- We need to provide a TextMate-compatible grammar definition. A very basic version of this is here: https://github.com/seldridge/firrtl-grammar/blob/main/grammars/firrtl.json Somewhat annoyingly, I think this needs to be in a separate repository (not
firrtl-spec
) whose directory structure matches that of a TextMate grammar definition/bundle. - We then go through the steps to add this grammar definition to Linguist via a PR.
Structurally, we should probably create a tool
directory inside firrtl-spec
to start bundling some of these editor-specific things.
Search query for number of files: https://github.com/search?q=path%3A*.fir+NOT+is%3Afork+circuit&type=code&ref=advsearch&query=path%3A*.fir+NOT+is%3Afork+circuit
By my count there are ~8k code samples on GitHub as gleaned from the following search:
https://github.com/search?p=10&q=extension%3Afir+NOT+flang+NOT+func+NOT+%22RUN%22+-user%3AKosinskiLab+-user%3Alukezya+-user%3ALourencoPonces+-user%3ALesible+-user%3Ajoaomiguelcaldeira&type=Code
This is slightly complicated as .fir
shares a file extension with FLANG IR.
This is slightly complicated as
.fir
shares a file extension with FLANG IR.
In theory, all FIRRTL must have a version identifier after that was introduced, and so maybe that can be checked to differentiate the two? (if not just 'are the first (non-whitespace?) characters "FIRRTL"?'). Just a thought.
Checking for the version string / FIRRTL in it would enable a trivial heuristic to differentiate the two. Great thinking.
Checking for the version string / FIRRTL in it would enable a trivial heuristic to differentiate the two. Great thinking.
Wouldn't all older FIRRTL files start with circuit
? Then if you check for FIRRTL
or circuit
your heuristic should work for virtually all firrtl files.
Checking for FIRRTL
or circuit
sounds great. 👍
Fixed with https://github.com/github-linguist/linguist/pull/6848.