runtime(comment): add <Plug>-mappings
vim9script <expr> mappings relying on imports cannot be evaluated outside of the script file with the imports, so do not work with plugins like vim-which-key, which evaluates <expr> mappings to apply them. Using <Plug> mappings is one way to address this, and has the added benefit of reading like a description for users finding the mappings. fixes: #17523 closes: #17563 Signed-off-by: Mark Woods <mwoods.online.ie@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
c877057e81
commit
1cbe3e89c9
28
runtime/pack/dist/opt/comment/plugin/comment.vim
vendored
28
runtime/pack/dist/opt/comment/plugin/comment.vim
vendored
@ -2,14 +2,28 @@ vim9script
|
||||
|
||||
# Maintainer: Maxim Kim <habamax@gmail.com>
|
||||
# Last Update: 2025 Mar 21
|
||||
# 2025 Jun 22 by Vim Project: add <Plug> mappings #17563
|
||||
|
||||
import autoload 'comment.vim'
|
||||
|
||||
nnoremap <silent> <expr> gc comment.Toggle()
|
||||
xnoremap <silent> <expr> gc comment.Toggle()
|
||||
nnoremap <silent> <expr> gcc comment.Toggle() .. '_'
|
||||
nnoremap <silent> <expr> <Plug>(comment-toggle) comment.Toggle()
|
||||
xnoremap <silent> <expr> <Plug>(comment-toggle) comment.Toggle()
|
||||
nnoremap <silent> <expr> <Plug>(comment-toggle-line) comment.Toggle() .. '_'
|
||||
nnoremap <silent> <expr> <Plug>(comment-toggle-end) comment.Toggle() .. '$'
|
||||
|
||||
onoremap <silent>ic <scriptcmd>comment.ObjComment(v:true)<CR>
|
||||
onoremap <silent>ac <scriptcmd>comment.ObjComment(v:false)<CR>
|
||||
xnoremap <silent>ic <esc><scriptcmd>comment.ObjComment(v:true)<CR>
|
||||
xnoremap <silent>ac <esc><scriptcmd>comment.ObjComment(v:false)<CR>
|
||||
onoremap <silent> <Plug>(comment-text-object-inner) <scriptcmd>comment.ObjComment(v:true)<CR>
|
||||
onoremap <silent> <Plug>(comment-text-object-outer) <scriptcmd>comment.ObjComment(v:false)<CR>
|
||||
xnoremap <silent> <Plug>(comment-text-object-inner) <esc><scriptcmd>comment.ObjComment(v:true)<CR>
|
||||
xnoremap <silent> <Plug>(comment-text-object-outer) <esc><scriptcmd>comment.ObjComment(v:false)<CR>
|
||||
|
||||
if get(g:, 'comment_mappings', true)
|
||||
nmap gc <Plug>(comment-toggle)
|
||||
xmap gc <Plug>(comment-toggle)
|
||||
nmap gcc <Plug>(comment-toggle-line)
|
||||
nmap gC <Plug>(comment-toggle-end)
|
||||
|
||||
omap ic <Plug>(comment-text-object-inner)
|
||||
omap ac <Plug>(comment-text-object-outer)
|
||||
xmap ic <Plug>(comment-text-object-inner)
|
||||
xmap ac <Plug>(comment-text-object-outer)
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user