diff --git a/BreakingChange.md b/BreakingChange.md new file mode 100644 index 0000000..f1e3253 --- /dev/null +++ b/BreakingChange.md @@ -0,0 +1,3 @@ +## 2018-07-14 +- remove g:fcitx#handle_insert_mode, use g:fcitx#insert_mode_behavior +- remove g:fcitx#handle_search_command, use g:fcitx#commandline_behavior diff --git a/doc/vim-fcitx.txt b/doc/vim-fcitx.txt index 7a1a782..d0e6d03 100644 --- a/doc/vim-fcitx.txt +++ b/doc/vim-fcitx.txt @@ -57,36 +57,33 @@ fcitx#restore_state() *fcitx#restore_state()* ============================================================================== VARIABLES *vim-fcitx-variables* -g:fcitx#handle_insert_mode *g:fcitx#handle_insert_mode* - type: bool - default: |v:true| - - Whether the plugin does setting for handling insert mode, - If you do setting yourself, set this variable to 0 or |v:false|. - -g:fcitx#handle_search_command *g:fcitx#handle_search_command* - type: bool - default: |v:false| - - Whether the plugin does setting for handling search mode. - For more information, see |vim-fcitx-search|. +g:fcitx#insert_mode_behavior *g:fcitx#insert_mode_behavior* + type: string + default: 'restore' + available: 'restore' 'off' 'nothing' + + 'restore' + turn off fcitx when you leave insert mode. + restore fcitx state when you re-enter insert mode. + 'off' + turn off fcitx when you leave insert mode. + 'nothing' + do nothing + +g:fcitx#commandline_behavior *g:fcitx#commandline_behavior* + type: string + default: 'restore' + available: 'restore' 'off' 'nothing' + + 'restore' + turn off fcitx when you leave command line. + restore fcitx state when you search again. + 'off' + turn off fcitx when you leave command line. + 'nothing' + do nothing ============================================================================== FAQ *vim-fcitx-faq* -*vim-fcitx-search* -Q: How can I handle fcitx state automatically when I enter/leave search command? - -A: -> - let g:fcitx#handle_search_command = v:true -< -If you want to do setting more flexible, you can refer below code. -> - nnoremap / (fcitx#restore_state() . '/') - nnoremap ? (fcitx#restore_state() . '?') - cnoremap (fcitx#inactivate_with_state() . '') - cnoremap (fcitx#inactivate_with_state() . '') -< - vim:tw=78:ts=8:sw=8:sts=0:ft=help:norl:noet:fen:fdl=0 diff --git a/plugin/fcitx.vim b/plugin/fcitx.vim index 6224bce..795a438 100644 --- a/plugin/fcitx.vim +++ b/plugin/fcitx.vim @@ -12,11 +12,20 @@ let s:save_cpo = &cpo set cpo&vim -if !exists('g:fcitx#handle_insert_mode') - let g:fcitx#handle_insert_mode = v:true +if !exists('g:fcitx#insert_mode_behavior') + let g:fcitx#insert_mode_behavior = 'restore' endif -if !exists('g:fcitx#handle_search_command') - let g:fcitx#handle_search_command = v:false +if !exists('g:fcitx#commandline_behavior') + let g:fcitx#commandline_behavior = 'off' +endif + +if exists('g:fcitx#handle_insert_mode') + echo 'g:fcitx#handle_insert_mode is removed.' + echo 'use g:fcitx#insert_mode_behavior instead.' +endif +if exists('g:fcitx#handle_search_command') + echo 'g:ibus#handle_search_command is removed.' + echo 'use g:fcitx#commandline_behavior instead.' endif augroup fcitx @@ -24,18 +33,27 @@ augroup fcitx au BufEnter,CmdwinEnter * let b:was_fcitx_on = v:false augroup END -if g:fcitx#handle_insert_mode +if g:fcitx#insert_mode_behavior == 'restore' augroup fcitx au InsertLeave * call fcitx#inactivate_with_state() au InsertEnter * call fcitx#restore_state() augroup END +elseif g:fcitx#insert_mode_behavior == 'off' + augroup fcitx + au InsertLeave * call fcitx#inactivate() + augroup END endif -if g:fcitx#handle_search_command - nnoremap / (fcitx#restore_state() . '/') - nnoremap ? (fcitx#restore_state() . '?') - cnoremap (fcitx#inactivate_with_state() . '') - cnoremap (fcitx#inactivate_with_state() . '') +if g:fcitx#commandline_behavior == 'restore' + augroup fcitx + au CmdLineLeave [/\?] call fcitx#inactivate_with_state() + au CmdLineEnter [/\?] call fcitx#restore_state() + au CmdLineLeave : call fcitx#inactivate() + augroup END +elseif g:fcitx#commandline_behavior == 'off' + augroup fcitx + au CmdLineLeave * call fcitx#inactivate() + augroup END endif let g:loaded_vim_fcitx = v:true diff --git a/test/deprecate.vim b/test/deprecate.vim new file mode 100644 index 0000000..e5cb403 --- /dev/null +++ b/test/deprecate.vim @@ -0,0 +1,2 @@ +let g:fcitx#handle_insert_mode = v:true +let g:fcitx#handle_search_command = v:true diff --git a/test/none.vim b/test/none.vim new file mode 100644 index 0000000..9ef7973 --- /dev/null +++ b/test/none.vim @@ -0,0 +1,2 @@ +let g:fcitx#insert_mode_behavior = 'none' +let g:fcitx#commandline_behavior = 'none' diff --git a/test/off.vim b/test/off.vim new file mode 100644 index 0000000..0ef7f9d --- /dev/null +++ b/test/off.vim @@ -0,0 +1,2 @@ +let g:fcitx#insert_mode_behavior = 'off' +let g:fcitx#commandline_behavior = 'off' diff --git a/test/restore.vim b/test/restore.vim new file mode 100644 index 0000000..1c32d85 --- /dev/null +++ b/test/restore.vim @@ -0,0 +1,2 @@ +let g:fcitx#insert_mode_behavior = 'restore' +let g:fcitx#commandline_behavior = 'restore'