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 generate
andtree-sitter test
to test. - Try the changes, run
tree-sitter parse a/fidl/file
to see the highlight. - Test all FIDL files in fuchsia repo
/sdk/fidl
,tree-sitter parse path/to/fuchsia/sdk/fidl/**.fidl | grep ERROR | grep fidl
ensure no error. - For FIDL syntax, You can check the FIDL grammar in Fuchsia repo.
grammar.js
is the definition of parsers.corpus/
stores test cases.queries
stores 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.
Require Helix version >= 358ac6bc1f512ca7303856dc904d4b4cdc1fe718 (will update this version when the commit landed to release)
Tree Sitter FIDL works out of box like other language support on helix.
hx --grammar fetch fidl
hx --grammar build fidl
mkdir -p ~/.config/helix/runtime/queries/
cp -r <path to helix source>/runtime/queries/fidl ~/.config/helix/runtime/queries
Charles Celerier has a WIP cl for Emacs usage https://fuchsia-review.git.corp.google.com/c/fuchsia/+/996186.
It does not have instructions yet, but you may able to figure out how it works.
- setup github actions to pull fuchsia repo and verify sdk every half year
- add instructions for emacs usage