aboutsummaryrefslogtreecommitdiff
path: root/plugin/casefmt.vim
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/casefmt.vim')
-rw-r--r--plugin/casefmt.vim30
1 files changed, 6 insertions, 24 deletions
diff --git a/plugin/casefmt.vim b/plugin/casefmt.vim
index 4c66a76..752aecd 100644
--- a/plugin/casefmt.vim
+++ b/plugin/casefmt.vim
@@ -52,13 +52,9 @@ function! CaseFmt_AddFormat(key, funcname) abort
\ . "<cmd>let g:CaseFmtFunction=function(\"\<SID>%s\")<cr>"
\ . "<cmd>set operatorfunc=\<SID>casefmt_do<cr>g@", a:key, a:funcname)
- exec printf("vnoremap <silent> <Plug>(casefmt-leader-no-set)%s "
- \ . "<cmd>let g:CaseFmtFunction=function(\"\<SID>%s\")<cr>"
- \ . "<cmd>call \<SID>casefmt_do(visualmode(), 1)<cr>", a:key, a:funcname)
endfunction
-nmap <silent> <Plug>(casefmt-leader) <cmd>let g:CaseFmtProcessor=function("<SID>casefmt_default_processor")<cr><Plug>(casefmt-leader-no-set)
-vmap <silent> <Plug>(casefmt-leader) <cmd>let g:CaseFmtProcessor=function("<SID>casefmt_default_processor")<cr>gv<Plug>(casefmt-leader-no-set)
+noremap <silent> <Plug>(casefmt-leader) <cmd>let g:CaseFmtProcessor=function("<SID>casefmt_default_processor")<cr><Plug>(casefmt-leader-no-set)
for [k, v] in items(s:case_fmts)
call CaseFmt_AddFormat(k, v)
@@ -69,34 +65,20 @@ if g:casefmt_include_bindings
exec printf("vmap <silent> %s <Plug>(casefmt-leader)", g:casefmt_leader)
endif
-nmap <silent> <Plug>(casefmt-leader)j <cmd>let g:CaseFmtProcessor=function("<SID>casefmt_joiner")<cr><Plug>(casefmt-leader-no-set)
-vmap <silent> <Plug>(casefmt-leader)j <cmd>let g:CaseFmtProcessor=function("<SID>casefmt_joiner")<cr>gv<Plug>(casefmt-leader-no-set)
+noremap <silent> <Plug>(casefmt-leader)j <cmd>let g:CaseFmtProcessor=function("<SID>casefmt_joiner")<cr><Plug>(casefmt-leader-no-set)
function! s:casefmt_do(type, ...) abort
- if a:0
- silent exe "norm! gvy"
- elseif a:type == 'line'
- " yank the text described by the motion
- silent exe "norm! '[V']y"
- else
- silent exe "norm! `[v`]y"
- endif
- let yanked = getreg('"', 1, v:true)
- let yankedtype = getregtype('"')
+ let cb = {}
if !exists('g:CaseFmtProcessor')
let g:CaseFmtProcessor = function("\<SID>casefmt_default_processor")
endif
+ let cb.operate = g:CaseFmtProcessor
- let changed = g:CaseFmtProcessor(yanked, yankedtype)
-
- call setreg('"', changed, yankedtype)
-
- norm gvp
+ call fieldmarshal#modifytext(a:type, cb)
- " Reset the yanked text to what it was originally.
- call setreg('"', yanked, yankedtype)
+ normal! ``
endfunction
" Default processor. Calls change case fmt on each word.