aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-09-29 01:54:17 +0200
committerTeddy Wing2020-09-29 01:54:17 +0200
commite230b24276a018701b6c3b8645c64fc8b1620985 (patch)
treee931f72c21ad32926fe71a3971c02997af4085d4
parent8a05e0113d49585ba1c22251695d5478b1c634ca (diff)
parent560239bbd9afb7dbf7ce846160bd687b1cfda03f (diff)
downloadvim-grappele-e230b24276a018701b6c3b8645c64fc8b1620985.tar.bz2
Merge branch 'fix-omap'
-rw-r--r--autoload/grappele.vim41
-rw-r--r--plugin/grappele.vim26
2 files changed, 26 insertions, 41 deletions
diff --git a/autoload/grappele.vim b/autoload/grappele.vim
index 74af532..c0835c9 100644
--- a/autoload/grappele.vim
+++ b/autoload/grappele.vim
@@ -1,36 +1,23 @@
-function! grappele#Grappele(line, ...)
- 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
+function! grappele#Grappele(line)
+ if a:line !=# 0
+ let s:line = a:line
endif
- if a:line ==# 0
- " Go to the end of the buffer
- $
- else
- let s:line = a:line
+ return 'G'
+endfunction
- call setpos('.', [
- \ l:current_buffer,
- \ a:line,
- \ l:column_position,
- \ l:column_offset
- \ ])
+function! grappele#Recall()
+ if exists('s:line')
+ return s:line . 'G'
endif
+
+ return ''
endfunction
-function! grappele#Recall(mode)
+function! grappele#ORecall()
if exists('s:line')
- call grappele#Grappele(s:line, a:mode, visualmode())
+ return ':normal! V' . s:line . "G\<cr>"
endif
+
+ return "\<C-c>"
endfunction
diff --git a/plugin/grappele.vim b/plugin/grappele.vim
index 9ab1400..be001ea 100644
--- a/plugin/grappele.vim
+++ b/plugin/grappele.vim
@@ -4,32 +4,30 @@ endif
let g:loaded_grappele = 1
-nnoremap <silent> <Plug>Grappele :<c-u>call grappele#Grappele(v:count, 'n')<cr>
-nnoremap <silent> <Plug>GrappeleRecall :<c-u>call grappele#Recall('n')<cr>
-vnoremap <silent> <Plug>GrappeleRecall :<c-u>call grappele#Recall('v')<cr>
-onoremap <silent> <Plug>GrappeleRecall :<c-u>call grappele#Recall('o')<cr>
+nnoremap <silent> <expr> <Plug>GrappeleRecall grappele#Recall()
+vnoremap <silent> <expr> <Plug>GrappeleRecall grappele#Recall()
+onoremap <silent> <expr> <Plug>GrappeleRecall grappele#ORecall()
-if !hasmapto('<Plug>Grappele') || !maparg('G', 'n')
- nnoremap <silent> G :<c-u>call grappele#Grappele(v:count, 'n')<cr>
+if !maparg('G', 'n')
+ nnoremap <silent> <expr> G grappele#Grappele(v:count)
endif
-if !hasmapto('<Plug>Grappele') || !maparg('G', 'v')
- vnoremap <silent> G
- \ :<c-u>call grappele#Grappele(v:count, 'v', visualmode())<cr>
+if !maparg('G', 'v')
+ vnoremap <silent> <expr> G grappele#Grappele(v:count)
endif
-if !hasmapto('<Plug>Grappele') || !maparg('G', 'o')
- onoremap <silent> G :<c-u>call grappele#Grappele(v:count, 'o')<cr>
+if !maparg('G', 'o')
+ onoremap <silent> <expr> G grappele#Grappele(v:count)
endif
-if !hasmapto('<Plug>GrappeleRecall') || !maparg('gG', 'n')
+if !hasmapto('<Plug>GrappeleRecall', 'n') || !maparg('gG', 'n')
nmap gG <Plug>GrappeleRecall
endif
-if !hasmapto('<Plug>GrappeleRecall') || !maparg('gG', 'v')
+if !hasmapto('<Plug>GrappeleRecall', 'v') || !maparg('gG', 'v')
vmap gG <Plug>GrappeleRecall
endif
-if !hasmapto('<Plug>GrappeleRecall') || !maparg('gG', 'o')
+if !hasmapto('<Plug>GrappeleRecall', 'o') || !maparg('gG', 'o')
omap gG <Plug>GrappeleRecall
endif