Tree-sitter for MCFunction
Tree-sitter grammar for modern Minecraft data pack function language. Supports 26.1 and earlier versions.
If you have any issues with parsing/highlighting, feel free to create an issue.
Neovim installation
Using lazy:
return
If needed, run: :TSInstall mcfunction.
Other editors
Refer to your editor's documentation on custom tree-sitter grammars.
I do not use other text editors, but I will happily accept contributions for plugins/add-ons/extensions that enable this grammar in a different editor.
Addendum
1 Macros
This grammar accepts $(macro)-s in many common places. However, some $(macro) tricks simply cannot be properly handled and can lead to errors.
2 Testing
[!IMPORTANT] Quantity ≠ quality. I used all projects I could scramble on my machine, but that does not mean that all possible syntax is covered.
Alongside tree-sitter tests, the grammar was tested on at least 19,293 files (~146,314 lines) worth of mcfunction code.
The script used can be found in this repository: test_local_files.sh. (Note: the script is sloppy, I did not intend for it to even be public)