Skip to content

ignamartinoli/_hyperscript.nvim

Repository files navigation

_hyperscript.nvim

Neovim support for _hyperscript, the small scripting language for the web. This plugin provides tree-sitter–powered syntax highlighting for ._hs files and injects highlighting into _hyperscript embedded in HTML, the _="…" attributes you write on elements.

It ships the tree-sitter-hyperscript grammar, builds it on install, and loads it through Neovim's built-in tree-sitter support.

Features

  • Syntax highlighting for ._hs files.
  • Injection into HTML: _, script, and data-script attributes, plus <script type="text/hyperscript"> blocks.
  • Zero runtime dependencies — the parser and queries are bundled and compiled at install time.
  • Optional: teaches the HTML language server that _ is a valid attribute, so it stops reporting invalid_attr on your _hyperscript.

Requirements

  • Neovim 0.10 or newer (built-in tree-sitter).
  • A C compiler (cc, gcc, or clang) and make on your PATH used once at install time, to compile the parser.

No tree-sitter CLI, no Node, no nvim-treesitter.

Installation

{
  'ignamartinoli/_hyperscript.nvim',
  build = 'make',
  ft = { 'hyperscript', 'html' },
  opts = true
}

That's the whole setup. build = "make" compiles the bundled grammar into a parser on install and whenever you run :Lazy build _hyperscript.nvim.

Other managers

The plugin has no Lua dependencies; any manager works as long as it runs make as the build step and fetches submodules (the grammar is vendored as one). Then call require("_hyperscript").setup() yourself.

Usage

Open a ._hs file and highlighting is on. Open an HTML file and _hyperscript inside attributes is highlighted too:

<button _="on click toggle .red then wait 2s then remove me">
  Click me
</button>

Troubleshooting

No highlighting in ._hs files. Check the parser built:

:lua =vim.api.nvim_get_runtime_file("parser/hyperscript.so", false)

If that's empty, the build didn't run. Run :Lazy build _hyperscript.nvim (or make in the plugin directory) and read the output — the usual cause is a missing C compiler or make.

No highlighting in HTML attributes. Confirm the HTML parser is present (injection needs the host parser) and that the plugin loaded — it must load for the html filetype, which the ft list above ensures.

HTML LSP reports invalid_attr on _. Make sure html_lsp is enabled (default). If your HTML language server only reads custom data from init_options at startup, run :LspRestart once after first install.

Related

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages