h-hg / fcitx.nvim

A Neovim plugin writing in Lua to switch and restore fcitx state for each buffer.
MIT License
85 stars 10 forks source link

怎么和Lunarvim集成? #2

Closed whjiang closed 2 years ago

whjiang commented 2 years ago

我在lunarvim的配置里就加了如下代码:

lvim.plugins = {
  { "h-hg/fcitx.nvim" },
}

已经安装成功,但还是不起作用。

请问应该怎么配置?

h-hg commented 2 years ago

首先,感谢您使用这个插件。 个人没有使用过 Lunarvim 这个 neovim 配置,按照 Lunarvim 的 README 浅试了一下,没有发现问题。

bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/master/utils/installer/install.sh)
// ~/.config/lvim/config.lua
-- Additional Plugins
lvim.plugins = {
  { "h-hg/fcitx.nvim" },
--     {"folke/tokyonight.nvim"},
--     {
--       "folke/trouble.nvim",
--       cmd = "TroubleToggle",
--     },
}

安装插件 :PackerUpdate

下面为本人的测试结果

example

请您查看一下您的 fcitx/fcitx5 配置,下面为个人的 fcitx5 配置

2022-06-18_10-33

或者检查一下 fcitx-remote/fcitx5-remote。

whjiang commented 2 years ago

谢谢你的回复。我试了,但还是没有成功。

我的环境是macbook pro 14 (M1 PRO芯片)。我使用的是fcitx-remote。下面是我在命令行上执行fcitx-remote的结果:

➜  lvim fcitx-remote -c
2022-06-21 09:07:17.849 fcitx-remote[67749:1108391] Changing to com.apple.keylayout.US
➜  lvim fcitx-remote -o
2022-06-21 09:07:24.337 fcitx-remote[67765:1108521] Changing to im.rime.inputmethod.Squirrel.Rime
➜  lvim fcitx-remote -n
im.rime.inputmethod.Squirrel.Rime
➜  lvim fcitx-remote
2
➜  lvim fcitx-remote -c
2022-06-21 09:07:39.246 fcitx-remote[67810:1108871] Changing to com.apple.keylayout.US
➜  lvim fcitx-remote
1

我的配置文件和你列的是一样的。

whjiang commented 2 years ago

知道原因了。

是因为在MAC上,没有定义DISPLAY变量,所以代码在这里退出了

if fcitx_cmd == "" or (vim.fn.exists("$DISPLAY") == 0 and vim.fn.exists("$WAYLAND_DISPLAY") == 0) then
h-hg commented 2 years ago

知道原因了。

是因为在MAC上,没有定义DISPLAY变量,所以代码在这里退出了

if fcitx_cmd == "" or (vim.fn.exists("$DISPLAY") == 0 and vim.fn.exists("$WAYLAND_DISPLAY") == 0) then

谢谢你的指出,我已经修改了这部分的代码,你可以看看是否可行。

whjiang commented 2 years ago

另外一个问题,在mac上切换输入法时,nvim会显示fcitx-remote的输出:

2022-06-21 09:07:24.337 fcitx-remote[67765:1108521] Changing to im.rime.inputmethod.Squirrel.Rime

虽然会马上消失,但看上去很讨厌。

h-hg commented 2 years ago

另外一个问题,在mac上切换输入法时,nvim会显示fcitx-remote的输出:

2022-06-21 09:07:24.337 fcitx-remote[67765:1108521] Changing to im.rime.inputmethod.Squirrel.Rime

虽然会马上消失,但看上去很讨厌。

用了一个有写 log 和 error 的程序试了一下,nvim 界面确实显示输出程序的输出, 您可以把代码的 22 行和 31 行的 os.execute 改为 vim.fn.system,试一试,这边没有 mac 测试,见谅。

Martins3 commented 2 years ago

@whjiang 我也是 m1 mac 的环境,在命令行使用 fcitx-remote -o 切换 rime 但是 https://github.com/h-hg/fcitx.nvim/blob/dcb6b70888aa893d3d223bb777d4117bbdac06a7/plugin/fcitx.lua#L35 得到的得到的 rime 是死掉的状态,你有遇到过吗?

Martins3 commented 2 years ago

@whjiang 我也是 m1 mac 的环境,在命令行使用 fcitx-remote -o 切换 rime 但是

https://github.com/h-hg/fcitx.nvim/blob/dcb6b70888aa893d3d223bb777d4117bbdac06a7/plugin/fcitx.lua#L35

得到的得到的 rime 是死掉的状态,你有遇到过吗?

我使用 https://github.com/neoclide/coc-imselect 解决了,但是过了一段时间,这个问题又出现了。:(

Martins3 commented 2 years ago

我修复了,但是不知道为什么

https://github.com/Martins3/fcitx.nvim/commit/f1c97b6821a76263a84addfe5c6fdb4178e90ca9

Asthestarsfalll commented 1 year ago

Manjaro 下无法使用😢确认了fcitx5的配置没有问题,也没有在初始化时退出。