-
Notifications
You must be signed in to change notification settings - Fork 764
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
Improvements to Commentary extension #493
Conversation
gcc now respects count Fixes VIM-1687
Fixes VIM-2589
Also introduces Visual support for the `g@` operator action
OperatorAction no longer normalises linewise ranges, but Exchange doesn't need this
5cbd69f
to
c83cc84
Compare
src/main/java/com/maddyhome/idea/vim/extension/commentary/CommentaryExtension.kt
Outdated
Show resolved
Hide resolved
override fun init() { | ||
putExtensionHandlerMapping(MappingMode.N, parseKeys("<Plug>Commentary"), owner, CommentMotionHandler(), false) | ||
putExtensionHandlerMapping(MappingMode.XO, parseKeys("<Plug>Commentary"), owner, CommentMotionVHandler(), false) | ||
putKeyMappingIfMissing(MappingMode.N, parseKeys("<Plug>CommentaryLine"), owner, parseKeys("gc_"), true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
src/main/java/com/maddyhome/idea/vim/extension/commentary/CommentaryExtension.kt
Outdated
Show resolved
Hide resolved
c83cc84
to
7d51768
Compare
Added a couple of new commits. This adds a backwards compatibility mapping so anyone using Also fixes VIM-2381, by adding a fallback. If the block comment action isn't available, then we fall back to the line comment (and vice versa). |
Yes, this looks awesome! Thank you for the updates. |
This PR adds a number of improvements and fixes to the Commentary extension:
gcc
does not take a countgc
text object. Can now use comment blocks as text objects, e.g. delete a comment block withdgc
, change a comment block withcgc
, yank withygc
, etc. Also allows forgcgc
to uncomment the current comment block (VIM-2125)gcu
mapping to uncomment the current comment block (mapped to<Plug>Commentary<Plug>Commentary
with is the same asgcgc
):Commentary
command, which works great for commands such as:%g/fun/Commentary
<Plug>Commentary
instead of<Plug>(CommentMotion)
. Old mappings are maintained for compatibilitySome implementation notes:
Commenter
services, but calls theCommentByLineComment
andCommentByBlockComment
actions directly. This is an important step to get this working with Rider, but it doesn't yet work because Rider's actions are async. The current implementation invokes the actions and then immediately resets selection and caret position. This causes Rider to terminate the async processing of the actions. I will follow up with a separate PR for this (VIM-1758, RIDER-38359)g@
. THis means the Commentary handler can now set an operator func and invokeg@
for both Normal and Visual mode.