-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Determine comment tokens from injection layers #7364
Comments
Thanks for making this issue especially the implementation notes, I meant to make it this morning but got caught up with work. This does conflict a tiny bit with my pr but if someone does implement this it shouldn't be too hard to rebase. I might also just pick this up after #4718 |
One complication will be that we have a language for comments that is injected into comments. We don't want to change the kind of comment tokens inside that obviously. I think we want to do something similar for indentation (see #7381) so having shared infrastructure for detecting language inside injections would be useful |
For indentation and textobjects I think we will want to switch to running queries across injections using something like: https://github.com/the-mikedavis/helix/blob/8483de78624be0b52dcd4144bc54a5b918d369cd/helix-core/src/syntax.rs#L1271-L1309 (currently that lives on #2857 but could be ported out). That QueryIter gives the LayerId of the current capture, so maybe the function in Syntax that gets a LayerConfiguration by byte range should actually be two functions: find the LayerId for a given byte range and then find a LanguageConfiguration for a LayerId. |
Note that I didn't mean indent queries (altough those should also be run across injections) but determining what kind of indent to use (tab, single space, four spaces,...). We could use th layerid from the query for autoindent but not for manual indent with Splitting the functions in two sounds like a good idea tough 👍 |
I was looking at this to see if it overlapped with #9320 at all. They look like separate problems unless we want to do a large refactor of how the We need to store some data on |
so any thing new about this ? or is there any experimental branch to test ? |
toggle_comments
should take language injections into account. For example in HTML:To do this we should look at the byte range for each Range in the current Selection and find the LanguageLayer in
doc.syntax()
(Syntax
) with the smallest/deepest range that completely covers the selection range. We will then need a way to find the LanguageConfiguration for a given LanguageLayer and then we can use that LanguageConfiguration'scomment_token
for that range in the selection.The changes for this will conflict with #1505 / #4718 so this feature may be better off waiting for those changes to land.
The text was updated successfully, but these errors were encountered: