-
Notifications
You must be signed in to change notification settings - Fork 73
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
Is it possible to get matchup to work with treesitter injections? #352
Comments
I believe injections should be supported but it depends on the treesitter
language. If I recall correctly it should be simple as adding an elixir
query to get matchup to recognize.
…On Mon, Jul 1, 2024 at 10:55 PM Peter Richards ***@***.***> wrote:
*Is your feature request related to a problem? Please describe.*
I love this plugin by the way. But I have a slight edge case in Elixir.
Elixir can have it's html templates in a separate file with a .html.heex
extension. Currently vim-matchup works a charm for these files. HTML markup
can also be embedded within an Elixir file(this is a somewhat newer thing,
but seems to be moving more in this direction). These files have the
regular Elixir extension .ex, and HTML is denoted in the file as follows:
def some_elixir_function(assigns) do
~H"""
<div>some html stuff here</div>
"""
end
Everything from the ~H""" to the next """" is HTML, even though the
overall file is of filetype elixir.
This is one place where matchup doesn't work for me, but I would love it
did, and wanted to open this to see what it would take. Of course I'm happy
to put the work in, but am a little lost on what the right direction is.
From my limited knowledge of Treesitter, it seems to use something called
injections to denote a part of a file that is following different syntax
rules than the rest of the file.
I notice in the after/queries/* there isn't currently one for Elixir.
Would writing one likely fix this issue? If so I'm happy to look into
writing one, but wasn't sure if that was A. What was needed and B. If there
is something else needed too.
*Describe the solution you'd like*
Ideally some way to let the plugin be aware of the HTML syntax within the
non-HTML file.
*Describe alternatives you've considered*
*Additional context*
Again, I'm happy to do the grunt work/write the queries, but just wanted
to float it by you to see if it's a lot more work than it's worth, or if
it's doable.
Thanks!
—
Reply to this email directly, view it on GitHub
<#352>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSY3DOKWYOJS276XD6VVOLZKIJC5AVCNFSM6AAAAABKGUPZFCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM4DKMBYGYYTGNQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Hey @andymass I've been playing around to try to get this to work because I miss matchup dearly every time I'm working with HTML embedded into an elixir document. This is the query i've cobbled together based on looking at other queries, as well as the syntax tree from
Here's a screenshot of some example code + TS inspect: However with this I get I also tried the following query, as well as copying the current HTML query verbatim:
but even those still gave me the "Invalid node type 'tag'" in the Elixir file, even though the InspectTree does seem to show that those names are correct(or at least the equivalent of what the HTML query seems to be matching again in an HTML file. I'm wondering if you have any pointers about where I might be getting stuck. I'm not sure if there's some filetype stuff that I need to update. Currently I have a
On another note, the HTML tag matching works correctly for filetypes of Thanks in advance. I appreciate your time and effort. |
As is so often the case, I manage to get it working just minutes after posting for help. Though the way I got it working was not via TS, but rather |
Is your feature request related to a problem? Please describe.
I love this plugin by the way. But I have a slight edge case in Elixir. Elixir can have it's html templates in a separate file with a
.html.heex
extension. Currently vim-matchup works a charm for these files. HTML markup can also be embedded within an Elixir file(this is a somewhat newer thing, but seems to be moving more in this direction). These files have the regular Elixir extension.ex
, and HTML is denoted in the file as follows:Everything from the
~H"""
to the next"""
is HTML, even though the overall file is of filetypeelixir
.This is one place where matchup doesn't work for me, but I would love if it did, and wanted to open this to see what it would take. Of course I'm happy to put the work in, but am a little lost on what the right direction is.
From my limited knowledge of Treesitter, it seems to use something called injections to denote a part of a file that is following different syntax rules than the rest of the file.
I notice in the
after/queries/*
there isn't currently one for Elixir. Would writing one likely fix this issue? If so I'm happy to look into writing one, but wasn't sure if that was A. What was needed and B. If there is something else needed too.Describe the solution you'd like
Ideally some way to let the plugin be aware of the HTML syntax within the non-HTML file.
Describe alternatives you've considered
Additional context
Again, I'm happy to do the grunt work/write the queries, but just wanted to float it by you to see if it's a lot more work than it's worth, or if it's doable.
Thanks!
The text was updated successfully, but these errors were encountered: