diff options
author | Teddy Wing | 2020-09-26 13:50:44 +0200 |
---|---|---|
committer | Teddy Wing | 2020-09-29 01:15:08 +0200 |
commit | 802d388c9dcc1c75b0acd8bcfe75cbd66c76838d (patch) | |
tree | f23b5abb6d10f561f8f78fa25c0a5fbb817ccb1d /autoload | |
parent | 8a05e0113d49585ba1c22251695d5478b1c634ca (diff) | |
download | vim-grappele-802d388c9dcc1c75b0acd8bcfe75cbd66c76838d.tar.bz2 |
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 `<expr>` 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`.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/grappele.vim | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/autoload/grappele.vim b/autoload/grappele.vim index 74af532..418f365 100644 --- a/autoload/grappele.vim +++ b/autoload/grappele.vim @@ -1,36 +1,56 @@ function! grappele#Grappele(line, ...) - let l:current_buffer = 0 - let l:column_position = 0 - let l:column_offset = 0 + " let l:current_buffer = 0 + " let l:column_position = 0 + " let l:column_offset = 0 + " + " let l:mode = get(a:, 1, '') + " let l:visualmode = get(a:, 2, '') + " + " normal! m' + " + " if l:mode ==# 'v' + " execute 'normal! ' . l:visualmode + " elseif l:mode ==# 'o' + " normal! V + " endif + " + " if a:line ==# 0 + " " Go to the end of the buffer + " $ + " else + " let s:line = a:line + " + " call setpos('.', [ + " \ l:current_buffer, + " \ a:line, + " \ l:column_position, + " \ l:column_offset + " \ ]) + " endif - let l:mode = get(a:, 1, '') - let l:visualmode = get(a:, 2, '') + let l:line = '' - normal! m' - - if l:mode ==# 'v' - execute 'normal! ' . l:visualmode - elseif l:mode ==# 'o' - normal! V - endif - - if a:line ==# 0 - " Go to the end of the buffer - $ - else + if a:line !=# 0 let s:line = a:line - - call setpos('.', [ - \ l:current_buffer, - \ a:line, - \ l:column_position, - \ l:column_offset - \ ]) endif + + echom s:line . 'G' + return 'G' endfunction function! grappele#Recall(mode) if exists('s:line') - call grappele#Grappele(s:line, a:mode, visualmode()) + " call grappele#Grappele(s:line, a:mode, visualmode()) + + let l:line = s:line + + if a:mode ==# 'o' + " let l:line += 1 + elseif a:mode ==# 'v' + let l:line = visualmode() . l:line + endif + + echom 'Recall: ' . l:line + execute 'normal! ' . l:line . 'G' endif endfunction |