diff options
author | Josh Rahm <rahm@google.com> | 2022-09-16 06:30:48 +0000 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-09-16 06:30:48 +0000 |
commit | faf9b29a25da337431e1ddaaf95d06c8783262cf (patch) | |
tree | 501ed6036558c4826f07177bbc03b3314f211678 /plugin/supert.vim | |
parent | 534f8ccabd777d419fc88aed28c7dc10a6637392 (diff) | |
download | fieldmarshal.vim-wip.tar.gz fieldmarshal.vim-wip.tar.bz2 fieldmarshal.vim-wip.zip |
wipwip
Diffstat (limited to 'plugin/supert.vim')
-rw-r--r-- | plugin/supert.vim | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/plugin/supert.vim b/plugin/supert.vim index f4a8e85..e3db464 100644 --- a/plugin/supert.vim +++ b/plugin/supert.vim @@ -6,13 +6,9 @@ endif let s:last = [] -let s:last_char = '' +let s:insert_char = '' function! s:getchar() - echom "Is not repeating? " . string(! exists('v:repeating') || ! v:repeating) - if ! exists('v:repeating') || ! v:repeating - let s:last_char = nr2char(getchar()) - endif - return s:last_char + let s:insert_char = nr2char(getchar()) endfunction function! s:do_search(type, vis) abort @@ -21,16 +17,18 @@ function! s:do_search(type, vis) abort elseif a:type == ',' call s:do_last(1, a:vis) else - call s:do_search_ch(a:type, a:vis, s:getchar()) + call s:do_search_ch(a:type, a:vis, s:insert_char) endif endfunction function! s:do_last(inv, vis) abort if len(s:last) < 2 + + return return endif - let type = s:last[0] + le] type = s:last[0] let ch = s:last[1] if a:inv @@ -56,10 +54,22 @@ function! s:do_search_ch(type, vis, ch) let pattern = a:ch - if a:type == 't' - let pattern = '\zs\_.\ze' . pattern - elseif a:type == 'T' - let pattern = pattern . '\zs\_.\ze' + " if a:vis != '' + if a:type == 'f' + let pattern = pattern + elseif a:type == 'F' + let pattern = pattern + endif + " else + " if a:type == 't' + " let pattern = '\zs\_.\ze' . pattern + " elseif a:type == 'T' + " let pattern = pattern . '\zs\_.\ze' + " endif + " endif + + if a:vis != '' + exec "normal! v" endif let i = 0 @@ -69,53 +79,43 @@ function! s:do_search_ch(type, vis, ch) endwhile endfunction -nnoremap <Plug>(supert-replace-t) <cmd>call <SID>do_search('t', '')<cr> -nnoremap <Plug>(supert-replace-T) <cmd>call <SID>do_search('T', '')<cr> -nnoremap <Plug>(supert-replace-f) <cmd>call <SID>do_search('f', '')<cr> -nnoremap <Plug>(supert-replace-F) <cmd>call <SID>do_search('F', '')<cr> - -vnoremap <Plug>(supert-replace-t) <cmd>call <SID>do_search('t', 'v')<cr> -vnoremap <Plug>(supert-replace-T) <cmd>call <SID>do_search('T', 'v')<cr> -vnoremap <Plug>(supert-replace-f) <cmd>call <SID>do_search('f', 'v')<cr> -vnoremap <Plug>(supert-replace-F) <cmd>call <SID>do_search('F', 'v')<cr> - -onoremap <Plug>(supert-replace-t) <cmd>call <SID>do_search('t', 'o')<cr> -onoremap <Plug>(supert-replace-T) <cmd>call <SID>do_search('T', 'o')<cr> -onoremap <Plug>(supert-replace-f) <cmd>call <SID>do_search('f', 'o')<cr> -onoremap <Plug>(supert-replace-F) <cmd>call <SID>do_search('F', 'o')<cr> +nnoremap <M-t> + \ <cmd>call <sid>getchar() + \ <bar>call <sid>do_search('t', '')<cr> -onoremap <Plug>(supert-replace-,) <cmd>call <SID>do_search(',', 'o')<cr> -onoremap <Plug>(supert-replace-;) <cmd>call <SID>do_search(';', 'o')<cr> - -vnoremap <Plug>(supert-replace-,) <cmd>call <SID>do_search(',', 'v')<cr> -vnoremap <Plug>(supert-replace-;) <cmd>call <SID>do_search(';', 'v')<cr> - -nnoremap <Plug>(supert-replace-,) <cmd>call <SID>do_search(',', '')<cr> -nnoremap <Plug>(supert-replace-;) <cmd>call <SID>do_search(';', '')<cr> +function! s:prepare_operation(t, op) + let s:operator = a:op + let s:type = a:t + let s:insert_char = nr2char(getchar()) + call feedkeys("\<esc>") + call feedkeys(printf("%s\<plug>(srtf-post)", s:operator)) +endfunction -if g:supert_provide_bindings - nnoremap <M-t> <Plug>(supert-replace-t) - nnoremap <M-T> <Plug>(supert-replace-T) - nnoremap <M-f> <Plug>(supert-replace-f) - nnoremap <M-F> <Plug>(supert-replace-F) +onoremap <leader>t <Plug>(srtf-to) +onoremap <leader>f <Plug>(srtf-fo) +onoremap <leader>T <Plug>(srtf-To) +onoremap <leader>F <Plug>(srtf-Fo) - vnoremap <M-t> <Plug>(supert-replace-t) - vnoremap <M-T> <Plug>(supert-replace-T) - vnoremap <M-f> <Plug>(supert-replace-f) - vnoremap <M-F> <Plug>(supert-replace-F) +nnoremap <leader>t <Plug>(srtf-t) +nnoremap <leader>f <Plug>(srtf-f) +nnoremap <leader>T <Plug>(srtf-T) +nnoremap <leader>F <Plug>(srtf-F) - onoremap <M-t> <Plug>(supert-replace-t) - onoremap <M-T> <Plug>(supert-replace-T) - onoremap <M-f> <Plug>(supert-replace-f) - onoremap <M-F> <Plug>(supert-replace-F) +nnoremap <Plug>(srtf-t) <cmd>call <sid>getchar()<bar>call <sid>do_search('t', '')<cr> +nnoremap <Plug>(srtf-f) <cmd>call <sid>getchar()<bar>call <sid>do_search('f', '')<cr> +nnoremap <Plug>(srtf-T) <cmd>call <sid>getchar()<bar>call <sid>do_search('T', '')<cr> +nnoremap <Plug>(srtf-F) <cmd>call <sid>getchar()<bar>call <sid>do_search('F', '')<cr> - vnoremap <M-;> <Plug>(supert-replace-;) - vnoremap <M-,> <Plug>(supert-replace-,) +onoremap <Plug>(srtf-to) <cmd>call <sid>prepare_operation('t', v:operator)<cr> +onoremap <Plug>(srtf-fo) <cmd>call <sid>prepare_operation('f', v:operator)<cr> +onoremap <Plug>(srtf-To) <cmd>call <sid>prepare_operation('T', v:operator)<cr> +onoremap <Plug>(srtf-Fo) <cmd>call <sid>prepare_operation('F', v:operator)<cr> - nnoremap <M-;> <Plug>(supert-replace-;) - nnoremap <M-,> <Plug>(supert-replace-,) +" is this a question? Or is that? - onoremap <M-;> <Plug>(supert-replace-;) - onoremap <M-,> <Plug>(supert-replace-,) -endif +onoremap <Plug>(srtf-post) <cmd>call <sid>do_search_postchar('v')<cr> +function! s:do_search_postchar(vis) abort + echom printf("do_search(%s, %s)", s:type, a:vis) + call s:do_search(s:type, a:vis) +endfunction |