Skip to content

Commit

Permalink
Version 1.1
Browse files Browse the repository at this point in the history
* remove warning about not using Python interface
* messages translate into English as fcitx supports more and more languages
  • Loading branch information
lilydjwg authored and vim-scripts committed May 20, 2012
1 parent 748342e commit f83971b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
25 changes: 15 additions & 10 deletions README
@@ -1,18 +1,23 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=3764

(fcitx is a Chinese input method so no English description.)
Keep and restore fcitx state for each buffer separately when leaving/re-entering insert mode. Like always typing English in normal mode, but Chinese in insert mode.

Fcitx 输入法自动切换
Requires: fcitx 3.6 or later, 4.0 or later will be better.

在离开/重新进入插入模式时自动切换输入法状态,以便在普通模式下始终是英文输入模式,切换回插入模式时恢复离开时的输入法输入模式。状态为每个缓冲区单独保存,所以在中文文档和英文代码间交叉跳转编辑也得心应手!
Developing: It's a part of https://github.com/lilydjwg/dotvim

无需任何配置!
A mirror repo: https://github.com/vim-scripts/fcitx.vim

要求:
fcitx 版本 3.6 以上,建议 fcitx 4.0 以上
Warning:
1, It will be faster and better with Python (3 or 2) enabled Vim. But some old version Vim enabled both Python 2 & 3 may have some issues.
2, If you use Vim in terminal, to avoid the Esc delay, please set 'ttimeoutlen' to 100 or some other value. And check screen's 'maptimeout' or tmux's 'escape-time' option if you use it too.

可选:
Python 3 或者 Python 支持以获得更快更好的效果。注意对于 vim 版本<7.3.288,如果同时编译了 Python 2 & 3 支持,因为此 vim 不能同时运行两个版本的 Python,而本脚本首先检查 Python3,所以会导致出错或者 Python 2 不可用。

开发:
它是 https://github.com/lilydjwg/dotvim 的一部分
在离开或重新进入插入模式时自动记录和恢复每个缓冲区各自的输入法状态,以便在普通模式下始终是英文输入模式,切换回插入模式时恢复离开前的输入法输入模式。

要求: fcitx 版本 3.6 以上,建议 fcitx 4.0 以上。

注意事项:
1. Vim 如有 Python 3或2 支持可以获得更快更好的效果。但对于较旧的 Vim 版本,如果同时编译了 Python 2 & 3 支持,因为此 Vim 不能同时运行两个版本的 Python,而本脚本首先检查 Python 3,所以会导致出错或者 Python 2 不可用。
2. 终端下请设置 Vim 'ttimeoutlen' 选项为较小值(如100),否则退出插入模式时会有较严重的延迟。同样会造成延迟的还有 screen 的 maptimeout 选项以及 tmux 的 escape-time 选项。

4 changes: 2 additions & 2 deletions plugin/fcitx.py
Expand Up @@ -16,7 +16,7 @@ def fcitxtalk(command=None):
try:
sock.connect(fcitxsocketfile)
except socket.error:
vim.command('echohl WarningMsg | echo "fcitx.vim: socket 连接出错" | echohl NONE')
vim.command('echohl WarningMsg | echo "fcitx.vim: socket connection error" | echohl NONE')
return
try:
if not command:
Expand All @@ -27,7 +27,7 @@ def fcitxtalk(command=None):
elif command == 'o':
sock.send(FCITX_OPEN)
else:
raise ValueError('未知命令')
raise ValueError('unknown fcitx command')
finally:
sock.close()

Expand Down
10 changes: 4 additions & 6 deletions plugin/fcitx.vim
@@ -1,7 +1,8 @@
scriptencoding utf-8
" fcitx.vim 记住插入模式小企鹅输入法的状态
" fcitx.vim remember fcitx's input state for each buffer
" Author: lilydjwg
" Maintainer: lilydjwg
" Version: 1.1
" URL: http://www.vim.org/scripts/script.php?script_id=3764
" ---------------------------------------------------------------------
" Load Once:
if &cp || exists("g:loaded_fcitx") || !exists('$DISPLAY') || exists('$SSH_TTY')
Expand All @@ -12,9 +13,6 @@ if has("python3")
elseif has("python")
let python3 = 0
else
echohl WarningMsg
echomsg "fcitx.vim: 没有 Python 支持,尝试使用旧版本。"
echohl None
runtime so/fcitx.vim
finish
endif
Expand All @@ -30,7 +28,7 @@ if !filewritable(s:fcitxsocketfile) "try again
let s:fcitxsocketfile = s:fcitxsocketfile . '.0'
if !filewritable(s:fcitxsocketfile)
echohl WarningMsg
echomsg "没有找到 fcitx 的 socket 文件,fcitx.vim 没有载入。"
echomsg "socket file of fcitx not found, fcitx.vim not loaded."
echohl None
finish
endif
Expand Down

0 comments on commit f83971b

Please sign in to comment.