Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tree-sitters EEx and HEEx #2093

Merged
merged 4 commits into from Apr 13, 2022
Merged

Conversation

the-mikedavis
Copy link
Member

@the-mikedavis the-mikedavis commented Apr 13, 2022

EEx and HEEx are templating languages for Elixir.

I thought about pulling in HEEx before (#881) but it needed the incremental injections refactor in order to use combined injections (#1378).

The highlights are not perfect because of the whitespace sensitivity of tree-sitter-elixir. I've removed the error highlighting in tree-sitter-elixir queries to make it less noticeable. It may take a bit to fix that so I think we're better off adding heex with "good enough" syntax highlights for now (see also elixir-lang/tree-sitter-elixir#2 (comment)). I could be persuaded to drop the commit that removes error highlighting though.

Also updates tree-sitter-elixir with a fix for a case that bugged me during editing (elixir-lang/tree-sitter-elixir#33)

The new revision handles a case that I come across often: a stab
clause (i.e. '->') with an empty right hand side:

    Enum.map(xs, fn x ->
    end)

The old version would parse the "end" token as an error.

This is technically valid syntax but more importantly it comes up
very often when editing, and the old revision would flicker between
the keyword highlight and the warning highlight.
This will become more important with the HEEx grammar being added.
Error highlighting with the Elixir grammar is a bit jumpy because
in some scenarios, a bit of missing syntax can force tree-sitter to
give up on error recovery and mark the entire tree as an error.
This ends up looking bad when editing. We don't typically highlight
error nodes so I'm inclined to leave it out of the highlights here.
EEx is an templating language for Elixir. Since the incremental
parsing refactor we can used combined injections which allows us
to add EEx support.
HEEx is a templating engine on top of Elixir's EEx templating
language specific to HTML that is included in Phoenix.LiveView
(though I think the plan is to eventually include it in base
Phoenix). It's a superset of EEx with some additional features
like components and slots.

The injections don't work perfectly because the Elixir grammar is
newline sensitive (the _terminator rule). See
elixir-lang/tree-sitter-elixir#24
for more information.
@archseer archseer merged commit 4836bb3 into helix-editor:master Apr 13, 2022
@the-mikedavis the-mikedavis deleted the md-eex-heex branch April 13, 2022 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants