diff --git a/plugin/fcitx.py b/plugin/fcitx.py index 3dc9ef5..9456653 100644 --- a/plugin/fcitx.py +++ b/plugin/fcitx.py @@ -20,8 +20,10 @@ class FcitxComm(): try: Fcitx = FcitxComm() + fcitx_loaded = True except dbus.exceptions.DBusException as e: vim.command('echohl WarningMsg | echom "fcitx.vim not loaded: %s" | echohl NONE' % e) + fcitx_loaded = False def may_reconnect(func): @functools.wraps(func) diff --git a/plugin/fcitx.vim b/plugin/fcitx.vim index 6a414e9..779ba13 100644 --- a/plugin/fcitx.vim +++ b/plugin/fcitx.vim @@ -14,8 +14,10 @@ let g:loaded_fcitx = 1 try " abort on fail exe 'py3file' expand(':r') . '.py' - au InsertLeave * py3 fcitx2en() - au InsertEnter * py3 fcitx2zh() + if py3eval('fcitx_loaded') + au InsertLeavePre * py3 fcitx2en() + au InsertEnter * py3 fcitx2zh() + endif endtry " --------------------------------------------------------------------- " Restoration And Modelines: