From 802d388c9dcc1c75b0acd8bcfe75cbd66c76838d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 26 Sep 2020 13:50:44 +0200 Subject: Trying to fix omap (WIP) gG omap works characterwise but should work linewise. Adding V to the gG omap causes >17G to indent 17 times instead of once. Try changing `G` to an `` mapping to simplify the code, allowing it to work more exactly like the normal `G`. This resulted in moving the logic to `grappele#Recall()`, causing problems for `gG`. --- plugin/grappele.vim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'plugin') diff --git a/plugin/grappele.vim b/plugin/grappele.vim index 9ab1400..e04c8e4 100644 --- a/plugin/grappele.vim +++ b/plugin/grappele.vim @@ -4,22 +4,22 @@ endif let g:loaded_grappele = 1 -nnoremap Grappele :call grappele#Grappele(v:count, 'n') -nnoremap GrappeleRecall :call grappele#Recall('n') -vnoremap GrappeleRecall :call grappele#Recall('v') -onoremap GrappeleRecall :call grappele#Recall('o') +nnoremap Grappele grappele#Grappele(v:count, 'n') +nnoremap GrappeleRecall :call grappele#Recall('n') +vnoremap GrappeleRecall :call grappele#Recall('v') +onoremap GrappeleRecall :call grappele#Recall('o') if !hasmapto('Grappele') || !maparg('G', 'n') - nnoremap G :call grappele#Grappele(v:count, 'n') + nnoremap G grappele#Grappele(v:count, 'n') endif if !hasmapto('Grappele') || !maparg('G', 'v') - vnoremap G - \ :call grappele#Grappele(v:count, 'v', visualmode()) + vnoremap G + \ grappele#Grappele(v:count, 'v', visualmode()) endif if !hasmapto('Grappele') || !maparg('G', 'o') - onoremap G :call grappele#Grappele(v:count, 'o') + onoremap G grappele#Grappele(v:count, 'o') endif if !hasmapto('GrappeleRecall') || !maparg('gG', 'n') -- cgit v1.2.3 From e07089624f0f8b8ba3f024bbf3c0c1a735522d06 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 26 Sep 2020 22:24:54 +0200 Subject: Fix `gG` omap by removing count Previously, if we stored a number in `s:line`, for example with `17G`, then `>gG` would cause lines .,17 to be indented 17 times due to the use of `V`. When I removed `V` from the omap, any commands using `gG` operated characterwise, when they should operate linewise. Found this answer from Liu Sha (https://stackoverflow.com/users/7026980/liu-sha) https://stackoverflow.com/questions/4261177/discarding-count-in-expr-mappings/53182922#53182922 that shows how to discard the count for different types of mappings: > nnoremap s "@_" . ToNthSpace() > vnoremap s "@_" . ToNthSpace() > onoremap s printf(":normal %s\", ToNthSpace()) The `:normal!` looks like it discards the count, so this gives us what we want. Adapted the suggestion into a new `` omap that indents only once for e.g. .,17. --- plugin/grappele.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/grappele.vim b/plugin/grappele.vim index e04c8e4..21c5cc7 100644 --- a/plugin/grappele.vim +++ b/plugin/grappele.vim @@ -7,7 +7,7 @@ let g:loaded_grappele = 1 nnoremap Grappele grappele#Grappele(v:count, 'n') nnoremap GrappeleRecall :call grappele#Recall('n') vnoremap GrappeleRecall :call grappele#Recall('v') -onoremap GrappeleRecall :call grappele#Recall('o') +onoremap GrappeleRecall grappele#ORecall() if !hasmapto('Grappele') || !maparg('G', 'n') nnoremap G grappele#Grappele(v:count, 'n') -- cgit v1.2.3 From b39b957b700e98035dd8aa7608feab71d6181c95 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 29 Sep 2020 01:08:31 +0200 Subject: Change v_gG and o_gG to mappings Fix visual mode bug where when the cursor is at the top of a visual selection, pressing `gG` changes the bottom of the visual selection instead of the top. --- plugin/grappele.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugin') diff --git a/plugin/grappele.vim b/plugin/grappele.vim index 21c5cc7..f85b2b4 100644 --- a/plugin/grappele.vim +++ b/plugin/grappele.vim @@ -5,8 +5,8 @@ let g:loaded_grappele = 1 nnoremap Grappele grappele#Grappele(v:count, 'n') -nnoremap GrappeleRecall :call grappele#Recall('n') -vnoremap GrappeleRecall :call grappele#Recall('v') +nnoremap GrappeleRecall grappele#Recall('n') +vnoremap GrappeleRecall grappele#Recall('v') onoremap GrappeleRecall grappele#ORecall() if !hasmapto('Grappele') || !maparg('G', 'n') -- cgit v1.2.3 From 47a6ae90ca533f32576c88b21b988d92d33f865c Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 29 Sep 2020 01:12:15 +0200 Subject: grappele#Grappele(): Remove varargs This function no longer needs any extra arguments. --- plugin/grappele.vim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'plugin') diff --git a/plugin/grappele.vim b/plugin/grappele.vim index f85b2b4..97b81e7 100644 --- a/plugin/grappele.vim +++ b/plugin/grappele.vim @@ -10,16 +10,15 @@ vnoremap GrappeleRecall grappele#Recall('v') onoremap GrappeleRecall grappele#ORecall() if !hasmapto('Grappele') || !maparg('G', 'n') - nnoremap G grappele#Grappele(v:count, 'n') + nnoremap G grappele#Grappele(v:count) endif if !hasmapto('Grappele') || !maparg('G', 'v') - vnoremap G - \ grappele#Grappele(v:count, 'v', visualmode()) + vnoremap G grappele#Grappele(v:count) endif if !hasmapto('Grappele') || !maparg('G', 'o') - onoremap G grappele#Grappele(v:count, 'o') + onoremap G grappele#Grappele(v:count) endif if !hasmapto('GrappeleRecall') || !maparg('gG', 'n') -- cgit v1.2.3 From 145c155e419fdcc73129771d8fbb3c32a77295a8 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 29 Sep 2020 01:18:33 +0200 Subject: plugin/grappele.vim: Remove `Grappele` mapping Since the plugin doesn't use this mapping any more due to the performance delay, let's remove it. Tells people that it shouldn't be used. --- plugin/grappele.vim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'plugin') diff --git a/plugin/grappele.vim b/plugin/grappele.vim index 97b81e7..5b6a046 100644 --- a/plugin/grappele.vim +++ b/plugin/grappele.vim @@ -4,20 +4,19 @@ endif let g:loaded_grappele = 1 -nnoremap Grappele grappele#Grappele(v:count, 'n') nnoremap GrappeleRecall grappele#Recall('n') vnoremap GrappeleRecall grappele#Recall('v') onoremap GrappeleRecall grappele#ORecall() -if !hasmapto('Grappele') || !maparg('G', 'n') +if !maparg('G', 'n') nnoremap G grappele#Grappele(v:count) endif -if !hasmapto('Grappele') || !maparg('G', 'v') +if !maparg('G', 'v') vnoremap G grappele#Grappele(v:count) endif -if !hasmapto('Grappele') || !maparg('G', 'o') +if !maparg('G', 'o') onoremap G grappele#Grappele(v:count) endif -- cgit v1.2.3 From f8bbf6e991d6a5d9768715c0cc915875bc9d9bc9 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 29 Sep 2020 01:31:17 +0200 Subject: grappele#Recall(): Remove special handling for visual mode Now that this is an `` mapping, we don't need any special handling for visual mode as this will be taken care of automatically. Remove the `mode` argument as it's no longer used. --- plugin/grappele.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugin') diff --git a/plugin/grappele.vim b/plugin/grappele.vim index 5b6a046..fe531af 100644 --- a/plugin/grappele.vim +++ b/plugin/grappele.vim @@ -4,8 +4,8 @@ endif let g:loaded_grappele = 1 -nnoremap GrappeleRecall grappele#Recall('n') -vnoremap GrappeleRecall grappele#Recall('v') +nnoremap GrappeleRecall grappele#Recall() +vnoremap GrappeleRecall grappele#Recall() onoremap GrappeleRecall grappele#ORecall() if !maparg('G', 'n') -- cgit v1.2.3 From 560239bbd9afb7dbf7ce846160bd687b1cfda03f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 29 Sep 2020 01:51:35 +0200 Subject: plugin/grappele.vim: Add mode to `hasmapto()` call Since these `` mappings are mode-specific, ensure we specify the mode in the `hasmapto()` call. --- plugin/grappele.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugin') diff --git a/plugin/grappele.vim b/plugin/grappele.vim index fe531af..be001ea 100644 --- a/plugin/grappele.vim +++ b/plugin/grappele.vim @@ -20,14 +20,14 @@ if !maparg('G', 'o') onoremap G grappele#Grappele(v:count) endif -if !hasmapto('GrappeleRecall') || !maparg('gG', 'n') +if !hasmapto('GrappeleRecall', 'n') || !maparg('gG', 'n') nmap gG GrappeleRecall endif -if !hasmapto('GrappeleRecall') || !maparg('gG', 'v') +if !hasmapto('GrappeleRecall', 'v') || !maparg('gG', 'v') vmap gG GrappeleRecall endif -if !hasmapto('GrappeleRecall') || !maparg('gG', 'o') +if !hasmapto('GrappeleRecall', 'o') || !maparg('gG', 'o') omap gG GrappeleRecall endif -- cgit v1.2.3