mirror of
https://github.com/lilydjwg/fcitx.vim.git
synced 2026-01-12 01:28:10 +08:00
Version 1.2
support to specify fcitx socket file by environment variable $FCITX_SOCKET
This commit is contained in:
parent
4904d73230
commit
1e3c080aaa
3 changed files with 19 additions and 64 deletions
2
README
2
README
|
|
@ -12,7 +12,6 @@ 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.
|
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.
|
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.
|
||||||
|
|
||||||
|
|
||||||
在离开或重新进入插入模式时自动记录和恢复每个缓冲区各自的输入法状态,以便在普通模式下始终是英文输入模式,切换回插入模式时恢复离开前的输入法输入模式。
|
在离开或重新进入插入模式时自动记录和恢复每个缓冲区各自的输入法状态,以便在普通模式下始终是英文输入模式,切换回插入模式时恢复离开前的输入法输入模式。
|
||||||
|
|
||||||
要求: fcitx 版本 3.6 以上,建议 fcitx 4.0 以上。
|
要求: fcitx 版本 3.6 以上,建议 fcitx 4.0 以上。
|
||||||
|
|
@ -21,3 +20,4 @@ Warning:
|
||||||
1. Vim 如有 Python 3或2 支持可以获得更快更好的效果。但对于较旧的 Vim 版本,如果同时编译了 Python 2 & 3 支持,因为此 Vim 不能同时运行两个版本的 Python,而本脚本首先检查 Python 3,所以会导致出错或者 Python 2 不可用。
|
1. Vim 如有 Python 3或2 支持可以获得更快更好的效果。但对于较旧的 Vim 版本,如果同时编译了 Python 2 & 3 支持,因为此 Vim 不能同时运行两个版本的 Python,而本脚本首先检查 Python 3,所以会导致出错或者 Python 2 不可用。
|
||||||
2. 终端下请设置 Vim 'ttimeoutlen' 选项为较小值(如100),否则退出插入模式时会有较严重的延迟。同样会造成延迟的还有 screen 的 maptimeout 选项以及 tmux 的 escape-time 选项。
|
2. 终端下请设置 Vim 'ttimeoutlen' 选项为较小值(如100),否则退出插入模式时会有较严重的延迟。同样会造成延迟的还有 screen 的 maptimeout 选项以及 tmux 的 escape-time 选项。
|
||||||
|
|
||||||
|
如果你需要跨主机使用 fcitx.vim,请参考此文: http://lilydjwg.is-programmer.com/2012/7/27/using-fcitx-remote-interface-remotely-via-socat.34729.html
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
" fcitx.vim remember fcitx's input state for each buffer
|
" fcitx.vim remember fcitx's input state for each buffer
|
||||||
" Author: lilydjwg
|
" Author: lilydjwg
|
||||||
" Version: 1.1
|
" Version: 1.2
|
||||||
" URL: http://www.vim.org/scripts/script.php?script_id=3764
|
" URL: http://www.vim.org/scripts/script.php?script_id=3764
|
||||||
" ---------------------------------------------------------------------
|
" ---------------------------------------------------------------------
|
||||||
" Load Once:
|
" Load Once:
|
||||||
if &cp || exists("g:loaded_fcitx") || !exists('$DISPLAY') || exists('$SSH_TTY')
|
if &cp || exists("g:loaded_fcitx") || !exists('$DISPLAY') || exists('$SSH_TTY') || has('gui_macvim')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
if has("python3")
|
if has("python3")
|
||||||
|
|
@ -19,18 +19,22 @@ endif
|
||||||
let s:keepcpo = &cpo
|
let s:keepcpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
" this is quicker than expand()
|
" this is quicker than expand()
|
||||||
let s:fcitxsocketfile = '/tmp/fcitx-socket-' . $DISPLAY
|
if exists('$FCITX_SOCKET')
|
||||||
if !filewritable(s:fcitxsocketfile) "try again
|
let s:fcitxsocketfile = $FCITX_SOCKET
|
||||||
if strridx(s:fcitxsocketfile, '.') > 0
|
else
|
||||||
let s:fcitxsocketfile = strpart(s:fcitxsocketfile, 0,
|
let s:fcitxsocketfile = '/tmp/fcitx-socket-' . $DISPLAY
|
||||||
\ strridx(s:fcitxsocketfile, '.'))
|
if !filewritable(s:fcitxsocketfile) "try again
|
||||||
else
|
if strridx(s:fcitxsocketfile, '.') > 0
|
||||||
let s:fcitxsocketfile = s:fcitxsocketfile . '.0'
|
let s:fcitxsocketfile = strpart(s:fcitxsocketfile, 0,
|
||||||
if !filewritable(s:fcitxsocketfile)
|
\ strridx(s:fcitxsocketfile, '.'))
|
||||||
echohl WarningMsg
|
else
|
||||||
echomsg "socket file of fcitx not found, fcitx.vim not loaded."
|
let s:fcitxsocketfile = s:fcitxsocketfile . '.0'
|
||||||
echohl None
|
if !filewritable(s:fcitxsocketfile)
|
||||||
finish
|
echohl WarningMsg
|
||||||
|
echomsg "socket file of fcitx not found, fcitx.vim not loaded."
|
||||||
|
echohl None
|
||||||
|
finish
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
49
so/fcitx.vim
49
so/fcitx.vim
|
|
@ -1,49 +0,0 @@
|
||||||
" fcitx.vim 记住插入模式小企鹅输入法的状态
|
|
||||||
" Author: lilydjwg
|
|
||||||
" Maintainer: lilydjwg
|
|
||||||
" Last Change: 2010-11-18
|
|
||||||
" Note: 另有使用 Python3 接口的新版本
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Load Once:
|
|
||||||
if (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
||||||
" Windows 下不要载入
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
if !exists('$DISPLAY')
|
|
||||||
" 没有 X,不要载入
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
if &cp || exists("g:loaded_fcitx") || !executable("fcitx-remote")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let s:keepcpo = &cpo
|
|
||||||
let g:loaded_fcitx = 1
|
|
||||||
set cpo&vim
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Functions:
|
|
||||||
function Fcitx2en()
|
|
||||||
let inputstatus = system("fcitx-remote")
|
|
||||||
if inputstatus == 2
|
|
||||||
let b:inputtoggle = 1
|
|
||||||
call system("fcitx-remote -c")
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
function Fcitx2zh()
|
|
||||||
try
|
|
||||||
if b:inputtoggle == 1
|
|
||||||
call system("fcitx-remote -o")
|
|
||||||
let b:inputtoggle = 0
|
|
||||||
endif
|
|
||||||
catch /inputtoggle/
|
|
||||||
let b:inputtoggle = 0
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Autocmds:
|
|
||||||
au InsertLeave * call Fcitx2en()
|
|
||||||
au InsertEnter * call Fcitx2zh()
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Restoration And Modelines:
|
|
||||||
let &cpo=s:keepcpo
|
|
||||||
unlet s:keepcpo
|
|
||||||
" vim:fdm=expr:fde=getline(v\:lnum-1)=~'\\v"\\s*-{20,}'?'>1'\:1
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue