summaryrefslogtreecommitdiff
path: root/plugin/vim-ai.vim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--plugin/vim-ai.vim21
1 files changed, 1 insertions, 20 deletions
diff --git a/plugin/vim-ai.vim b/plugin/vim-ai.vim
index b276355..5d156c3 100644
--- a/plugin/vim-ai.vim
+++ b/plugin/vim-ai.vim
@@ -4,31 +4,12 @@ if !has('python3')
finish
endif
-" detect if a visual selection is pending
+" detect if a visual selection is pending: https://stackoverflow.com/a/20133772
let g:vim_ai_is_selection_pending = 0
augroup vim_ai
autocmd!
- if exists('##ModeChanged')
- autocmd ModeChanged *:[vV\x16]*
- \ let g:vim_ai_is_selection_pending = 1
- autocmd ModeChanged [vV\x16]*:*
- \ let g:vim_ai_is_selection_pending =
- \ v:event.new_mode =~# '^c' &&
- \ (getcmdtype() =~# '[/?]' ||
- \ getcmdtype() ==# ':' && getcmdline() =~# "^\s*'<'>")
- else
- " workaround for version < 8.2.3424 from https://stackoverflow.com/a/20133772
autocmd CursorMoved *
\ let g:vim_ai_is_selection_pending = mode() =~# "^[vV\<C-v>]"
- autocmd CmdLineEnter,CmdwinEnter *
- \ if g:vim_ai_is_selection_pending && getcmdtype() ==# ':' |
- \ let g:vim_ai_is_selection_pending = getcmdline() =~# "^\s*'<'>" |
- \ endif
- autocmd CmdLineLeave,CmdwinLeave *
- \ if g:vim_ai_is_selection_pending && getcmdtype() !~# '[/?]' |
- \ let g:vim_ai_is_selection_pending = 0 |
- \ endif
- endif
augroup END
command! -range -nargs=? AI <line1>,<line2>call vim_ai#AIRun({}, <q-args>)