tree-sitter-hygen-template
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

tree-sitter-hygen-template

CI discord matrix crates npm pypi

Tree-sitter grammar for Hygen templates.

It extends the tree-sitter-embedded-template grammar.

Parser requirements

  • bash (optional): highlight of metadata.value when metadata.key is sh
  • javascript (optional): highlight of code nodes
  • regex (optional): highlight of metadata.value when metadata.key is after, before or skip_if
  • Any other parser that you want to use for dynamic injection

Usage in Editors

Neovim

  • hygen.nvim: plugin that integrates this grammar to your Neovim configuration.

Helix

To be added

Emacs

To be added

In General

You can get the built files from the release branch. If you have specific instructions for your editor, PR's are welcome.

Dynamic Injection

Thanks to content node of tree-sitter-embedded-template grammar, dynamic injections can be attached to template body.

File naming convention

Just add .hygen to the end of the file name, i.e.:

  • index.html.hygen
  • .gitignore.hygen
  • .tsconfig.json.hygen

Tree-sitter directive

To implement dynamic injection, is recommended to create a directive with the following name:

#inject-hygen-tmpl!

[!NOTE] The creation of this directive varies for each editor

This directive will the responsible to remove .hygen from the file name and use the rest of the file name to retrieve the parser to be used for dynamic injection. See implementations for more details.

[!WARNING] Ignore dynamic injection for *.ejs.hygen, *.erb.hygen and *.hygen.hygen files to avoid weird behaviours

Once created, add it to the end of injections.scm file that will be used by the editor:

; dynamic injection
((content) @injection.content
  (#inject-hygen-tmpl! "")
  (#set! injection.combined))

Implementations

hygen.nvim

References

Package Sidebar

Install

npm i tree-sitter-hygen-template

Weekly Downloads

1

Version

0.5.0

License

MIT

Unpacked Size

582 kB

Total Files

25

Last publish

Collaborators

  • hdoc