Git Product home page Git Product logo

fcitx.vim's Introduction

Keep and restore fcitx state for each buffer separately when leaving/re-entering insert mode or search mode. Like always typing English in normal mode, but Chinese in insert mode.

D-Bus only works with the same user so this won't work with sudo vim. See the fcitx5-server branch for an experimental implementation that supports sudo vim.

By default, it use python3 and D-Bus to toggle IME state. If you set g:fcitx5_remote to the executable path of fcitx5-remote BEFORE loading the plugin, it will use fcitx5-remote instead of python and D-Bus. In this case, python3 support is optional.

Usually fcitx5-remote mode is way faster to start up since Python script need quite some time for the initial load if you don't use any other plugins that load Python. The Python version will be faster while switching.

Base requirements:

  • fcitx 5

Requirements for Python mode (g:fcitx5_remote is not set):

  • Vim with Python 3 compiled in
  • The python-dbus package

Requirements for fcitx5-remote mode (g:fcitx5_remote is set):

  • fcitx5-remote

If you are using fcitx5-rime (which has its own state), let g:fcitx5_rime = 1 in your .vimrc.

The FcitxCurrentIM() function can be used to get current IM's name.

Links:

Warning:

  1. 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.

在离开或重新进入插入模式或搜索模式时自动记录和恢复每个缓冲区各自的输入法状态,以便在普通模式下始终是英文输入模式,切换回插入模式时恢复离开前的输入法输入模式。

D-Bus 只在同一用户时有效,所以使用 sudo vim 时本代码就失效了。在 fcitx5-server 分支有一个实验性的版本支持 sudo vim 的用法。

本插件默认会使用 Python 3 并通过 D-Bus 来切换输入法状态。 但如果你在加载插件之前设置了 g:fcitx5_remote 为你已安装的 fcitx5-remote 可执行文件的路径,那么本插件会使用它来切换输入法状态;此模式下本插件并不需要 Python。

如果你没有其他使用 Python 的 Vim 插件,本插件的 Python 模式初始化可能会显著拖慢启动时间;而 fcitx5-remote 模式则没有这个问题。Python 模式会在切换时更快。

基本要求:

  • fcitx 5

使用 Python 模式的要求(未设置 g:fcitx5_remote):

  • 带有 Python 3 支持的 Vim
  • python-dbus 包

使用 fcitx5-remote 模式的要求(需设置 g:fcitx5_remote):

  • fcitx5-remote

如果使用 fcitx5-rime(它自己有输入状态),在 .vimrc 中设置 let g:fcitx5_rime = 1

FcitxCurrentIM() 函数可以用于获取当前输入法的名字。

链接:

注意事项:

  1. 终端下请设置 Vim 'ttimeoutlen' 选项为较小值(如100),否则退出插入模式时会有较严重的延迟。同样会造成延迟的还有 screen 的 maptimeout 选项以及 tmux 的 escape-time 选项。
  2. 请在 fcitx5-configtool 中确认英语是第一个输入法,中文是第二个输入法,rime 用户可能需要设置 g:fcitx5_rime = 1

fcitx.vim's People

Contributors

gou4shi1 avatar lilydjwg avatar lokiiart avatar meijieru avatar ouuan avatar oxalica avatar t2hhbmek avatar zeertzjq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fcitx.vim's Issues

nvim lua 配置下如何 生效

vim 配置

image

fcitx 5 配置

安装了 fcitx5 和 fcitx5-rime
配置如下
image

用了aur 的 小鹤双拼 paru -S rime-flypy

nvim 下的表现

packersync 后 packerInstall 然后 重启 nvim 在 normal 为英文模式 按 i 切换到 中文模式 打中文 ,然后 esc 退出后

它还是中文模式 ,不是期待 的英文模式

请问我是哪里设置的不对么?

[FR] 禁止在Normal mode/visual mode输入中文,对各个mode分别管理输入法状态

有些情况下,用户可能会不小心在normal mode/visual line mode/ visual block mode切入中文,希望此插件可以禁止这种情况。
注:似乎本插件只区分了inserstion mode和非insertion mode,但是事实上个人感觉应该分为一下两类:
不可能输入中文的:
Normal, Visual 这两个mode中应该禁止中文(可以作为一个用户选项)
Select, Insert, Repleace, Command-line,这几个mode中有可能会输入中文,应该分别保存他们的输入法状态(比如当insert mode是打开输入法的时候,用户大概率期望command line mode没有打开输入法)

esc切换到英文速度很慢

按esc切换到英文很慢,大概要2、3秒;恢复为原来的状态很快,秒切。本来就是这样,还是就我的有问题?google拼音和系统默认的拼音输入法都是这样。应该不是输入法问题。
系统:Majaro 18.1.5
vim版本:vim8.1

好像响应的是timeoutlen而不是ttimeoutlen

设置了ttimeoutlen,发现退出Normal模式时还是要等好久才重置输入法为英文。然后设置了timeoutlen=100,发现有效果了。

我的Vim版本:

  • gvim 7.4-326
  • openSuse 42.3 Linux

无报错但无法使用

我的操作系统:arch linux + dde desktop
前提:fcitx-remote和fcitx5-remote均正常
我的尝试:
1.一开始我使用fcitx作为输入法,然后使用vim-plug从github安装fcitx.vim,无报错,但没有任何效果
2.尝试从https://www.vim.org/scripts/script.php?script_id=3764 下载1.2.6版本,按您的指示解压到~/.vim,情况依旧如上,此时我使用neovim,意识到放错了位置,纠正后依旧如上
3.尝试直接将您在plug/fcitx.vim的内容写入~/.config/nvim/init.vim,当我试图重新用nvim打开一个文件时,报错如下,同时该错误在我进行该操作之前用nvim打开您的plug/fcitx.vim时同样存在


Error detected while processing modelines:
line 248:
E992: Not allowed in a modeline when 'modelineexpr' is off: fde=getline(v:lnum-1)=~'\v"\s*-{20,}'?'>1':1


报错的是最后一行,一行注释, 248 " vim:fdm=expr:fde=getline(v\:lnum-1)=~'\\v"\\s*-{20,}'?'>1'\:1,去掉"后依旧报错,删除该行后不再报错
同时,还有一个错误,init.py不存在,于是把您的fcitx.py移动到init.vim所在目录,修改为init.py,不再报错

这里顺便运行了一下这个python文件,ModuleNotFoundError: No module named 'vim',这样看来您不是为neovim设计的,不过后来我又尝试了vim,所以还是补全了这个模块

至此,再无报错,但依旧无法使用

4.尝试使用fcitx5,重复 1 2 3,依旧如上
5.尝试使用vim,重复1 2 3,依旧如上
6.按您的博客设置了FCITX_SOCKET,依旧如上

`InsertLeavePre` is not a defined vim event

On line 18 of fcitx.vim on branch fcitx5

    au InsertLeavePre * py3 fcitx2en()

throws an error about no such event.

Changing to InsertLeave fixes the problem and the plugin works successfully (at least on my machine).

InseartLeavePre在vim里面没有这个event,换成InsertLeave可以解决这个问题。

How to specify environment variable $FCITX_SOCKET

Hi, I am really enjoying using this wonderful plugin to input Chinese characters.
I don't much about socket file and can not figure out how to set the environment variable $FCITX_SOCKET in this new version.
Could you please give an example about how to specify environment variable $FCITX_SOCKET?
I am currently using Ubuntu 16.04 LTS 64bit and Vim 8.0. Thanks.

不会配置...

请问"环境变量 $FCITX_SOCKET 指定要连接的套接字路径"是什么意思??

配置:环境变量 $FCITX_SOCKET 指定要连接的套接字路径,而非默认的。自版本 1.2.4 起,此变量若以 "@" 字符开头,则被认为是抽象套接字地址。

rime输入法没有效果

之前用过这个插件,当时用的是一个google拼音,一个英文输入法,使用shift切换输入法。是可以用的。
后来重装了manjaro,使用了rime输入法(只有一个输入法,没有添加单独的英文输入法),使用shift在rime输入法内部切换中英文。安装这个插件按esc没有变成英文状态。

我添加系统默认的拼音和默认的英文输入法,也是没有效果的。

vim和nvim都是不行的。

fcitx版本:4.2.9.7
manajro:20
桌面环境:kde5
vim环境:vim8 nvim 0.4.4

support fcitx5

Hi, thanks for your great work first.
Fcitx 5 is usable now, and I use it for my daily work. Unfortunately this plugin seems not work with it, anyway to fix it?

can I diable 'org.freedesktop.DBus.Error.NotSupported' warning?

When I run neovim from windows terminal, a warning like below will pop up, can I disable it?
fcitx.vim not loaded: org.freedesktop.DBus.Error.NotSupported: Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead
I guess this only happens when there is no destop environment. The warning won't show up when I use neovim from Xserver.

是否可以忽略上次退出插入模式时使用的中文输入法 , 在下次进入插入模式时启用英文输入法?

如果可以指定并且固定每次进入插入模式使用的输入法, 就可以实现盲操作, 不在大脑中记住上次插入模式用的输入法, 也不看显示器上输入法指示器的状态, 因为我确定进入插入模式一定是指定的输入法, 这样好像能提高一点效率? 我也不确定

再一个就是因为编辑文档中英文多, 中文少, 所以每次进入插入模式更大概率是首先需要输入英文.

是否有某个选项强制每次进入插入模式使用指定的输入法, 或者, 固定使用英文输入?

Error when installing: initialization check failed: GLib version too old (micro mismatch)

I'm using fcitx-lilydjwg-git-2:4.2.9.7.20200925-1. Recently I cannot use sogoupinyin in chrome. I found that if I replace these two files with those from vanilla fcitx, the problem will be solved.

Typing in English because my sogoupinyin is broken after upgrading fcitx-lilydjwg.

Cannot load module /usr/lib/gtk-2.0/2.10.0/immodules/im-fcitx.so: GModule (/usr/lib/gtk-2.0/2.10.0/immodules/im-fcitx.so) initialization check failed: GLib version too old (micro mismatch)
/usr/lib/gtk-2.0/2.10.0/immodules/im-fcitx.so does not export GTK+ IM module API: GModule (/usr/lib/gtk-2.0/2.10.0/immodules/im-fcitx.so) initialization check failed: GLib version too old (micro mismatch)
error: command failed to execute correctly
(3/6) Probing GTK3 input method modules...
Cannot load module /usr/lib/gtk-3.0/3.0.0/immodules/im-fcitx.so: GModule (/usr/lib/gtk-3.0/3.0.0/immodules/im-fcitx.so) initialization check failed: GLib version too old (micro mismatch)
/usr/lib/gtk-3.0/3.0.0/immodules/im-fcitx.so does not export GTK+ IM module API: GModule (/usr/lib/gtk-3.0/3.0.0/immodules/im-fcitx.so) initialization check failed: GLib version too old (micro mismatch)
error: command failed to execute correctly

E486:找不到模式:soclet

您好感谢您的回复 完整的信息就是E486:找不到模式:soclet 插件不起作用 切换模式 vim状态栏就回提示这个信息 然后就没有了 vim启动也没有报错 安装插件也没有报错

关于 ttimeoutlen

https://github.com/skywind3000/vim-quickui
这个老哥的插件理念貌似跟你相克,假如将 timeoutlen设置的过小,那么上面链接的那款插件就无法打开了。
就比如,这样的快捷键设置,nnoremap :call quickui#menu#open()。
另外,vnoremap y "+y 这样的也失效。

fcitx5+ssh场景实现

fcitx5分支中的通信通过dbus,请问如何单独控制本插件连接到远程dbus呢。

启动耗时较多

使用本插件后感觉vim启动速度明显变慢,使用vim-plugins-profile测试发现本插件耗时65ms

~ python vim-plugins-profile.py                                      (bilabila)
Running vim to generate startup logs... done.
Loading and processing logs... done.
Plugin directory: /home/bilabila/.config/nvim/plugged
====================================
Top 10 plugins slowing vim's startup
====================================
1        65.050   fcitx.vim
2         2.652   nvim-compe
3         1.717   vim-visual-multi
4         1.551   nvim-treesitter-context
5         1.190   nvim-treesitter
6         0.802   vim-autoformat
7         0.524   vim-indentwise
8         0.331   vim-expand-region
9         0.313   vim-surround
10        0.294   vim-tmux-navigator

有无方法优化?

[feature] change default value of g:fcitx5-remote

Now, user can change g:fcitx5-remote to decide whether to use python-dbus or fcitx5-remote. Why not:

if has('python3') and import dbus will not get NoModuleError
let fcitx5-remote = 0
else if executable('fcitx5-remote')
let fcitx5-remote = 1
else
warning to let user install requirements.

? It looks better because python-dbus is faster than fcitx5-remote. TIA!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.