From 45cfa4a0a16a31fd2a94e6ac7187e452287bbcf2 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 1 Sep 2022 12:18:37 -0600 Subject: fieldmarshal.vim: use instead of : to fix some bugs. --- autoload/hints.vim | 8 ++++---- plugin/casefmt.vim | 16 ++++++++-------- plugin/fall.vim | 20 ++++++++++---------- plugin/hints.vim | 6 +++--- plugin/joiner.vim | 12 ++++++------ plugin/subwords.vim | 24 ++++++++++++------------ plugin/supert.vim | 42 ++++++++++++++++++------------------------ 7 files changed, 61 insertions(+), 67 deletions(-) diff --git a/autoload/hints.vim b/autoload/hints.vim index 5a74386..7ab8797 100644 --- a/autoload/hints.vim +++ b/autoload/hints.vim @@ -54,7 +54,7 @@ function! s:display_hints(hints) abort "call nvim_buf_set_virtual_text( " \ 0, g:hints_ns, line - 1, [[tag, "Number"]], {}) - exec printf("sign define tag_%s text=%s texthl=LineNr", tag, tag) + exec printf("sign define tag_%s text=%s texthl=Number", tag, tag) exec printf("sign place %d line=%d name=tag_%s file=%s", s, line, tag, expand('%:p')) let s += 1 @@ -97,10 +97,10 @@ function! hints#runHints(visual) abort let line = get(hints, nr2char(c1) . nr2char(c2), -1) if line >= 0 - norm m' - if len(a:visual) - exec "norm gv" + if a:visual == 'o' + norm! V endif + norm m' call cursor(line, 1) norm ^ endif diff --git a/plugin/casefmt.vim b/plugin/casefmt.vim index fb271b5..3717925 100644 --- a/plugin/casefmt.vim +++ b/plugin/casefmt.vim @@ -45,16 +45,16 @@ let s:case_fmts = { function! CaseFmt_AddFormat(key, funcname) abort exec printf("noremap (casefmt-leader-no-set)%s " - \ . ":\let g:CaseFmtFunction=function(\"\%s\")" - \ . ":\set operatorfunc=\casefmt_dog@", a:key, a:funcname) + \ . "let g:CaseFmtFunction=function(\"\%s\")" + \ . "set operatorfunc=\casefmt_dog@", a:key, a:funcname) exec printf("vnoremap (casefmt-leader-no-set)%s " - \ . ":\let g:CaseFmtFunction=function(\"\%s\")" - \ . ":\call \casefmt_do(visualmode(), 1)", a:key, a:funcname) + \ . "let g:CaseFmtFunction=function(\"\%s\")" + \ . "call \casefmt_do(visualmode(), 1)", a:key, a:funcname) endfunction -nmap (casefmt-leader) :let g:CaseFmtProcessor=function("casefmt_default_processor")(casefmt-leader-no-set) -vmap (casefmt-leader) :let g:CaseFmtProcessor=function("casefmt_default_processor")gv(casefmt-leader-no-set) +nmap (casefmt-leader) let g:CaseFmtProcessor=function("casefmt_default_processor")(casefmt-leader-no-set) +vmap (casefmt-leader) let g:CaseFmtProcessor=function("casefmt_default_processor")gv(casefmt-leader-no-set) for [k, v] in items(s:case_fmts) call CaseFmt_AddFormat(k, v) @@ -65,8 +65,8 @@ if g:casefmt_include_bindings exec printf("vmap %s (casefmt-leader)", g:casefmt_leader) endif -nmap (casefmt-leader)j :let g:CaseFmtProcessor=function("casefmt_joiner")(casefmt-leader-no-set) -vmap (casefmt-leader)j :let g:CaseFmtProcessor=function("casefmt_joiner")gv(casefmt-leader-no-set) +nmap (casefmt-leader)j let g:CaseFmtProcessor=function("casefmt_joiner")(casefmt-leader-no-set) +vmap (casefmt-leader)j let g:CaseFmtProcessor=function("casefmt_joiner")gv(casefmt-leader-no-set) function! s:casefmt_do(type, ...) abort if a:0 diff --git a/plugin/fall.vim b/plugin/fall.vim index 05d4e6e..8aec2c0 100644 --- a/plugin/fall.vim +++ b/plugin/fall.vim @@ -3,34 +3,34 @@ noremap k fall#fall('k', '^\s*$') noremap j fall#fall('j', '^\s*$') " Text object to fall through whitepacea -onoremap k :exec "normal! V" . fall#fall('k', '^\s*$') -onoremap j :exec "normal! V" . fall#fall('j', '^\s*$') +onoremap k exec "normal! V" . fall#fall('k', '^\s*$') +onoremap j exec "normal! V" . fall#fall('j', '^\s*$') " Text object to fall though whitespace, but exclude the last line. -onoremap ik :exec "normal! V" . fall#fall('k', '^\s*$') . "j" -onoremap ij :exec "normal! V" . fall#fall('j', '^\s*$') . "k" +onoremap ik exec "normal! V" . fall#fall('k', '^\s*$') . "j" +onoremap ij exec "normal! V" . fall#fall('j', '^\s*$') . "k" " Text object to fall though whitespace, but exclude the last line. -onoremap ik :exec "normal! V" . fall#fall('k', '^\s*$') . "j" -onoremap ij :exec "normal! V" . fall#fall('j', '^\s*$') . "k" +onoremap ik exec "normal! V" . fall#fall('k', '^\s*$') . "j" +onoremap ij exec "normal! V" . fall#fall('j', '^\s*$') . "k" " Text objects to describe "falling" down, and then "falling" up. Equivalent to " VkOj -onoremap ai :exec "normal! V" +onoremap ai exec "normal! V" \ . fall#fall('j', '^\s*$') \ . "O" \ . fall#fall('k', '^\s*$') -onoremap ii :exec "normal! V" +onoremap ii exec "normal! V" \ . fall#fall('j', '^\s*$') \ . "kO" \ . fall#fall('k', '^\s*$') . 'j' -vnoremap ai :exec "normal! gv" +vnoremap ai exec "normal! gv" \ . fall#fall('j', '^\s*$') \ . "O" \ . fall#fall('k', '^\s*$') -vnoremap ii :exec "normal! gv" +vnoremap ii exec "normal! gv" \ . fall#fall('j', '^\s*$') \ . "kO" \ . fall#fall('k', '^\s*$') . 'j' diff --git a/plugin/hints.vim b/plugin/hints.vim index 47282ad..c962a75 100644 --- a/plugin/hints.vim +++ b/plugin/hints.vim @@ -1,3 +1,3 @@ -noremap :call hints#runHints("") -onoremap : call hints#runHints("V") -vnoremap : call hints#runHints("V") +noremap call hints#runHints("") +onoremap call hints#runHints("o") +vnoremap call hints#runHints("") diff --git a/plugin/joiner.vim b/plugin/joiner.vim index 26cb5a3..5345fbe 100644 --- a/plugin/joiner.vim +++ b/plugin/joiner.vim @@ -23,13 +23,13 @@ if ! exists('g:joiner_leader') let g:joiner_leader = '' endif -noremap (joiner)s :let g:JoinerJoinText=function('joiner#join_with_string'):set operatorfunc=joiner#dog@ -noremap (joiner)S :let g:JoinerJoinText=function('joiner#join_with_string_literal'):set operatorfunc=joiner#dog@ -noremap (joiner) :let g:JoinerJoinText=function('joiner#default_join'):set operatorfunc=joiner#dog@ +noremap (joiner)s let g:JoinerJoinText=function('joiner#join_with_string')set operatorfunc=joiner#dog@ +noremap (joiner)S let g:JoinerJoinText=function('joiner#join_with_string_literal')set operatorfunc=joiner#dog@ +noremap (joiner) let g:JoinerJoinText=function('joiner#default_join')set operatorfunc=joiner#dog@ -vnoremap (joiner)s :let g:JoinerJoinText=function('joiner#join_with_string')gv:call joiner#do(visualmode(), 1) -vnoremap (joiner)S :let g:JoinerJoinText=function('joiner#join_with_string_literal')gv:call joiner#do(visualmode(), 1) -vnoremap (joiner) :let g:JoinerJoinText=function('joiner#default_join')gv:call joiner#do(visualmode(), 1) +vnoremap (joiner)s let g:JoinerJoinText=function('joiner#join_with_string')gvcall joiner#do(visualmode(), 1) +vnoremap (joiner)S let g:JoinerJoinText=function('joiner#join_with_string_literal')call joiner#do(visualmode(), 1) +vnoremap (joiner) let g:JoinerJoinText=function('joiner#default_join')call joiner#do(visualmode(), 1) if g:joiner_include_bindings exec printf("vnoremap %s (joiner)", g:joiner_leader) diff --git a/plugin/subwords.vim b/plugin/subwords.vim index 067eb2c..4b95ddd 100644 --- a/plugin/subwords.vim +++ b/plugin/subwords.vim @@ -8,10 +8,10 @@ " of snake_case identifier will include the underscores (_). The 'i_' references " the ci_ -onoremap (inner-sub-word) :exec "norm " . subwords#visual(v:true, v:false) -vnoremap (inner-sub-word) :exec "norm " . subwords#visual(v:true, v:false) -onoremap (around-sub-word) :exec "norm " . subwords#visual(v:true, v:true) -vnoremap (around-sub-word) :exec "norm " . subwords#visual(v:true, v:true) +onoremap (inner-sub-word) exec "norm " . subwords#visual(v:true, v:false) +vnoremap (inner-sub-word) exec "norm " . subwords#visual(v:true, v:false) +onoremap (around-sub-word) exec "norm " . subwords#visual(v:true, v:true) +vnoremap (around-sub-word) exec "norm " . subwords#visual(v:true, v:true) if ! exists('g:subwords_include_bindings') let g:subwords_include_bindings = 1 @@ -19,18 +19,18 @@ endif " These mappings are the same as above, except prefer_camel is turned off, so " snake case is used in the case of a conflict. -onoremap (inner-sub-word-prefer-snake) :exec "norm " . subwords#visual(v:false, v:false) -vnoremap (inner-sub-word-prefer-snake) :exec "norm " . subwords#visual(v:false, v:false) -onoremap (around-sub-word-prefer-snake) :exec "norm " . subwords#visual(v:false, v:true) -vnoremap (around-sub-word-prefer-snake) :exec "norm " . subwords#visual(v:false, v:true) +onoremap (inner-sub-word-prefer-snake) exec "norm " . subwords#visual(v:false, v:false) +vnoremap (inner-sub-word-prefer-snake) exec "norm " . subwords#visual(v:false, v:false) +onoremap (around-sub-word-prefer-snake) exec "norm " . subwords#visual(v:false, v:true) +vnoremap (around-sub-word-prefer-snake) exec "norm " . subwords#visual(v:false, v:true) " Movement keys for subwords. These all have prefer_camel set to true, the idea " being it's pretty easy to navigate underscores with f_ and t_, but more " difficult to navigate upper case letters. -noremap (next-subword) :silent! call subwords#next(v:false, v:true) -noremap (prev-subword) :silent! call subwords#next(v:false, v:false) -vnoremap (next-subword) visualmode() . ":\silent! call subwords#next(visualmode(), v:true)\m'gv``" -vnoremap (prev-subword) visualmode() . ":\silent! call subwords#next(visualmode(), v:false)m'gv``" +noremap (next-subword) silent! call subwords#next(v:false, v:true) +noremap (prev-subword) silent! call subwords#next(v:false, v:false) +vnoremap (next-subword) silent! call subwords#next(visualmode(), v:true) +vnoremap (prev-subword) silent! call subwords#next(visualmode(), v:false) noremap (subwords-replace-;) subwords#repeat(';') noremap (subwords-replace-,) subwords#repeat(',') diff --git a/plugin/supert.vim b/plugin/supert.vim index c32fc3e..f4a8e85 100644 --- a/plugin/supert.vim +++ b/plugin/supert.vim @@ -62,12 +62,6 @@ function! s:do_search_ch(type, vis, ch) let pattern = pattern . '\zs\_.\ze' endif - if a:vis == 'v' - exec "norm gv" - elseif a:vis == 'o' - exec "norm v" - endif - let i = 0 while i < v:count1 call search(pattern, flags) @@ -75,29 +69,29 @@ function! s:do_search_ch(type, vis, ch) endwhile endfunction -nnoremap (supert-replace-t) :call do_search('t', '') -nnoremap (supert-replace-T) :call do_search('T', '') -nnoremap (supert-replace-f) :call do_search('f', '') -nnoremap (supert-replace-F) :call do_search('F', '') +nnoremap (supert-replace-t) call do_search('t', '') +nnoremap (supert-replace-T) call do_search('T', '') +nnoremap (supert-replace-f) call do_search('f', '') +nnoremap (supert-replace-F) call do_search('F', '') -vnoremap (supert-replace-t) :call do_search('t', 'v') -vnoremap (supert-replace-T) :call do_search('T', 'v') -vnoremap (supert-replace-f) :call do_search('f', 'v') -vnoremap (supert-replace-F) :call do_search('F', 'v') +vnoremap (supert-replace-t) call do_search('t', 'v') +vnoremap (supert-replace-T) call do_search('T', 'v') +vnoremap (supert-replace-f) call do_search('f', 'v') +vnoremap (supert-replace-F) call do_search('F', 'v') -onoremap (supert-replace-t) :call do_search('t', 'o') -onoremap (supert-replace-T) :call do_search('T', 'o') -onoremap (supert-replace-f) :call do_search('f', 'o') -onoremap (supert-replace-F) :call do_search('F', 'o') ; +onoremap (supert-replace-t) call do_search('t', 'o') +onoremap (supert-replace-T) call do_search('T', 'o') +onoremap (supert-replace-f) call do_search('f', 'o') +onoremap (supert-replace-F) call do_search('F', 'o') -onoremap (supert-replace-,) :call do_search(',', 'o') -onoremap (supert-replace-;) :call do_search(';', 'o') +onoremap (supert-replace-,) call do_search(',', 'o') +onoremap (supert-replace-;) call do_search(';', 'o') -vnoremap (supert-replace-,) :call do_search(',', 'v') -vnoremap (supert-replace-;) :call do_search(';', 'v') +vnoremap (supert-replace-,) call do_search(',', 'v') +vnoremap (supert-replace-;) call do_search(';', 'v') -nnoremap (supert-replace-,) :call do_search(',', '') -nnoremap (supert-replace-;) :call do_search(';', '') +nnoremap (supert-replace-,) call do_search(',', '') +nnoremap (supert-replace-;) call do_search(';', '') if g:supert_provide_bindings -- cgit