Skip to content

phoenixr-codes/tree-sitter-mcfunction

Repository files navigation

tree-sitter-mcfunction

Logo

mcfunction grammar for tree-sitter.

Preview

Note

This grammar is designed for Minecraft Bedrock Edition commands and not Java Edition commands.

Important

This project is still in development. The installation process will be simplified as soon as the grammar is considered stable.

Features

  • All commands
  • ✅ Good query highlights (e.g. if is highlighted as a conditional keyword, help is highlighted as a debug keyword, ...)
  • ✅ Selectors (e.g. @a[r=3])
  • ✅ JSON (used for "raw text" in tellraw and titleraw)
  • ✅ Comments
  • ✅ Markup/Formatting (e.g. §a)
  • ✅ Emojis (e.g. :heart:)

Editor Integration

Tip

For full compability, also make sure to have Tree-sitter grammar installed for JSON.

git clone https://github.com/phoenixr-codes/tree-sitter-mcfunction.git
cd tree-sitter-mcfunction

Neovim

local parsers = require("nvim-treesitter.parsers").get_parser_configs()

parsers.mcfunction = {
  install_info = {
    url = "https://github.com/phoenixr-codes/tree-sitter-mcfunction.git",
    files = { "src/parser.c" },
    branch = "main",
  },
}
mkdir -p ~/.config/nvim/queries/mcfunction
ln queries/*.scm ~/.config/nvim/queries/mcfunction

Helix

Important

Because Helix does not support language version 15, you need to use the helix branch.

# ~/.config/helix/languages.toml

[[grammar]]
name = "mcfunction"
source = { git = "https://github.com/phoenixr-codes/tree-sitter-mcfunction", rev = "<LATEST COMMIT HASH OF `helix` BRANCH>" }

[[language]]
scope = "source.mcfunction"
name = "mcfunction"
file-types = ["mcfunction"]
roots = ["manifest.json"]
comment-token = "#"
hx --grammar fetch
hx --grammar build
mkdir -p ~/.config/helix/runtime/queries/mcfunction
ln queries/*.scm ~/.config/helix/runtime/queries/mcfunction

References

Releases

Packages

Contributors

Languages