-
Notifications
You must be signed in to change notification settings - Fork 203
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
Make @comment.outer span multiline comment #133
Comments
Bump for feature request, would help a lot with long doc strings that need to be copied elsewhere. For python, I have a solution I use for folding, however it runs into an issue #154 |
Given a comment like this: # Reverses the contents of a String or IO object. (1)
#
# @param [String, #read] contents the contents to reverse (3)
# @return [String] the contents reversed lexically (4)
def reverse(contents)
end For
For
For
For
That said, there is some stuff like ruby's All said, I don't know that |
This would be very useful, has anyone tried it? |
I did some research into an implementation for this and came across a shortcoming; most parsers don't support nodes for the content of a comment. It's not possible to detect whether or not a comment is empty. Luckily, all languages have the capability of a comment content node, they just need to be implemented. For the languages that do support it, we have a few options of how to go about it: What @liaden suggested:
Add
Add
To preserve backwards compatibility, the |
Hi, |
@wilsonchen719 Latest nightly version of Neovim has builtin support for comment objects, the mapping for this text object is |
Hi @sassanh , |
@wilsonchen719 Maybe tree-sitter parser for Python is not installed, you can install it with |
Is your feature request related to a problem? Please describe.
Code comments are usually hard-wrapped, so I use
gw
/gq
to reflow long multiline comments when editing them. Unfortunately, when these are not separated by an empty line from preceding and following code, then theip
(inner paragraph) text object includes that as well, sogwip
/gqip
reflows even the code (which is unwanted and very probably wrong). So you have to resort to first visually selecting the comment and thengw
/gq
.Describe the solution you'd like
I'd love to use treesitter +
@comment.outer
to invokegw
/gq
over the appropriate range of text. However,@comment.outer
currently doesn't span multiline comments, it only extends to the current line. Would it be realistic to redefine it, so that e.g.gwac
(ifac
is configured as the@comment.outer
text object) reflows the entire multiline comment?Describe alternatives you've considered
If redefining
@comment.outer
is doable but not desirable for backwards compatibility reasons, then maybe a new textobject could be provided, something like@multiline_comment.outer
?Additional context
I'm specifically interesting in Python, but once a solution exists for one language, it should be fairly easy to extend it to other ones with similar syntax?
The text was updated successfully, but these errors were encountered: