keaising / im-select.nvim

Switch Input Method automatically depends on Neovim's edit mode
MIT License
170 stars 25 forks source link

im-select is not working with astronvim? #12

Closed suinming closed 1 year ago

suinming commented 1 year ago
  1. OS: Ubuntu 22.04(Fcitx5 installed)
  2. astronvim setting file (directory .config/nvim/lua/user/plugins/im-select.lua)
    return {
    "keaising/im-select.nvim",
    config = function()
    require("im-select").setup {
      default_im_select = "com.apple.keylayout.ABC",
    }
    end,
    }
  3. behavior I am switching between Chinese and English after I installed the plugin the input method did not switch automatically. the following is my Fctix config: Group1(for Chinese) image Group2(for English) image Anyone know why im-select doesn't work?
keaising commented 1 year ago

Have you tried to execute fcitx5-remote -n in your shell or :!fcitx5-remote -n in nvim command mode?

Could you please provide the result?

suinming commented 1 year ago

Thanks for your reply. The following is the result in shell. image The following is the result in neovim. image

keaising commented 1 year ago

You should make sure fcitx5-remote is included in nvim's path first.

im-select.nvim depends on fcitx5-remote to switch input methods.

keaising commented 1 year ago

BTW, your config default_im_select = "com.apple.keylayout.ABC" is not proper for fcitx5, it is default IM for macOS

suinming commented 1 year ago
  1. I set the environment variable in zsh so the fcitx5-remote is included in nvim's path
  2. change my nvim config to default_im_select = keyboard-us image But the plugins still not work. Any advice??
keaising commented 1 year ago

It seams that you use a different fcitx5-remote version than me, your fcitx5-remote is more like a fcitx-remote

Maybe you can:

  1. Make a alias export fcitx-remote=fcitx5-remote
  2. Make sure alias fcitx-remote works well in your nvim
  3. Set default command to fcitx-remote in config, e.g. default_command = 'fcitx-remote'
  4. Set default_im_select = 1

In this method you can only activation/inactivate IM, use fcitx5-remote as fcitx-remote

keaising commented 1 year ago

好像是中国人?

你的截图里显示你用的就是 Fcitx,不知道你的 fcitx5-remote 是咋来的,不是你自己改名字的吧?如果是你自己改名字的话就改回去,用 fcitx-remote 就好

由于获取不到当前输入法的名字,所以 im-select.nvim 对 fcitx-remote 只支持到开启和关闭输入法,不支持在多个输入法之间切换

还有一个问题是你的输入法分组可能也有问题, im-select.nvim 不支持切换分组,我不知道有多个分组的情况下会发生什么,只能你自己用 fcitx-remote 在命令行里试试了

im-select.nvim 本质上只是帮你在合适的时机调用 fcitx-remote,所以你得先确保它能正常用

suinming commented 1 year ago

我比較好奇fcitx5-remote -n-n 這個flag的意義?因為似乎沒有這個-n的選項

keaising commented 1 year ago

我装的 fcitx5 自带的 fcitx5-remote 有这个选项,意思是获取当前输入法的名字

你截图里的 fcitx5-remote 的行为和输出跟我安装的 fcitx 自带的 fcitx-remote 一致

suinming commented 1 year ago

首先,非常謝謝你的回覆。我蠻確定我使用的是fcitx5,還是沒弄懂為何沒有fcitx5-remote -n這個指令可以用。 但還是想分享一下我的處理方式:

    vim.api.nvim_create_autocmd({ "InsertLeave" }, {
      pattern = { "*" },
      callback = function()
        local input_status = tonumber(vim.fn.system "fcitx5-remote")
        if input_status == 1 then vim.fn.system "fcitx5-remote -t" end
      end,
    })

英文的部份input_status = 2, 中文的部份input_status = 1,所以若是離開insert mode將會自動把中文的輸入法切換為英文。

keaising commented 1 year ago

嗯嗯,跟我的 fcitx-remote 的表现完全一致,你可以考虑按照我上面说的,给 fcitx5-remote 加一个 alias 当成 fcitx-remote,然后配置 default_command = fcitx-remote ,这样就只需要写配置,不用写上面那些代码

Anyway,能跑就行