-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat: Determine comment tokens from injection layers #12759
Open
nik-rev
wants to merge
41
commits into
helix-editor:master
Choose a base branch
from
nik-rev:determine-comment-tokens
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,225
−354
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nik-rev
force-pushed
the
determine-comment-tokens
branch
from
February 2, 2025 22:36
63e26be
to
3281c81
Compare
nik-rev
changed the title
feat: Determine comment tokens from injection layers
fix: Determine comment tokens from injection layers
Feb 2, 2025
nik-rev
changed the title
fix: Determine comment tokens from injection layers
feat: Determine comment tokens from injection layers
Feb 2, 2025
…unting for comment tokens
…dded and removed chars
nik-rev
force-pushed
the
determine-comment-tokens
branch
from
February 2, 2025 23:19
019fe67
to
c585fca
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, if you had a file like this:
Pressing
Space + c
(toggle comment) on the JavaScript comment would've used the HTML comment token:This PR fixes that. Now, the comment token is properly recognized:
It also works for continue comment functionality (when pressing
o
or adding a newline, for example)Additionally, the PR adds a new
:tree-sitter-injections
command:`:tree-sitter-injections` output
With this file:
We get the following when we run
:tree-sitter-injections
:Languages Tested
I've added a lot of tests, each of which actually helped me fix a bug or two while I was implementing this. So I ended up extracting all comment-relating integration tests into a separate module
The core functionality works. What's left is to make sure that we do all we can to have individual languages work as well. For example, Svelte's comment tokens had to be adjusted in this PR for the best experience.
I've tested these languages manually as well. If you have a language which relies on injections, be sure to test it and comment here, I'll add it to the list.
JSX and TSX
These languages don't use tree-sitter injections:
Has just this injection:
Which means this PR won't affect them
You can use
Space + C
to comment JSX at the moment. It'd be nice if you could useSpace + c
to make line comments that use the tokens{/*
and*/}
though, as it uses//
right now.But to do this we could have
.tsx
and.jsx
languages usets
andjs
as the file's "main" language, and then when we injecttsx
andjsx
languages when we encounter a tag.Not exactly sure how to accomplish this though, and it's not really related to this PR (can be done as a follow up if I or someone figures out how to do this)
Closes #7364
Closes #11647
Related to to #9425