Warning
Disclaimer: This is not an officially supported Google product.
This is tree-sitter parser for FIDL files (Fuchsia Interface Definition Language).
It provides fast syntax tree based code highlighting and code folding for Fuchsia developers using tree-sitter supported editors (NeoVim / Emacs).
- Setup tree-sitter development, either rust cli or nodejs cli work. https://tree-sitter.github.io/tree-sitter/creating-parsers.
- Make changes, run
tree-sitter generateandtree-sitter testto test. - Try the changes, run
tree-sitter parse a/fidl/fileto see the highlight. - Test all FIDL files in fuchsia repo
/sdk/fidl,tree-sitter parse path/to/fuchsia/sdk/fidl/**.fidl | grep ERROR | grep fidlensure no error. - For FIDL syntax, You can check the FIDL grammar in Fuchsia repo.
grammar.jsis the definition of parsers.corpus/stores test cases.queriesstores syntax meanings for highlighting.
Require NeoVim version > 0.9 to use nvim-treesitter plugin.
:TSInstall fidl to install in NeoVim.
Add filetype mapping, you may add this to <nvim-config>/lua/options.lua:
vim.filetype.add({ extension = { fidl = "fidl" } })You may need to install using local parser and queries when you want to debug
queries/*.scm changes.
Add following to the place you config nvim-treesitter:
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.fidl = {
install_info = {
url = "path/to/tree-sitter-fidl",
files = { "src/parser.c" },
},
}and copy queries/* to nvim-runtime-dir/queries/fidl/, check :h rtp for how to locate the dir,
usually $XDG_CONFIG_HOME/nvim is one of the runtime-dir.
:TSInstall fidl to install, and :TSUpdate for update the parser.
Tree Sitter FIDL works out of box like other language support on helix.
hx --grammar fetch fidl
hx --grammar build fidl
Charles Celerier has a WIP cl for Emacs usage https://fxrev.dev/996186.
It does not have instructions yet, but you may able to figure out how it works.
- NeoVim (
nvim-treesitter): Revisions are updated automatically inlua/nvim-treesitter/parsers.lua. - Helix (
hx): Requires manually updating the grammar revision after this repository is updated (see helix-editor/helix#16319).