keaising / im-select.nvim

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

Not working on Windows #16

Closed madjxatw closed 12 months ago

madjxatw commented 1 year ago

I am using Windows 11 and managing plugins via lazy.nvim. The im-select binary is placed along with the nvim binary in the same directory, it can be accessed in Command Prompt and Powershell. However, with the default config, nvim keeps spawning terminal windows once launched.

I have to remove the "FocusGained" from the default events to prevent nvim from spawning terminal windows:

  {
    "keaising/im-select.nvim",
    opts = {
      set_default_events = { "VimEnter", "InsertLeave", "CmdlineLeave" },
    },
    config = true
  }

Now a terminal windows flashes around 2~3 times on each press of Esc, but input method does not get switched.

BTW, I could mange to switch to the US keyboard by directly executing :!im-select 1033.

keaising commented 1 year ago

Wrong config, have a try with this one:

    {
        "keaising/im-select.nvim",
        config = function()
            require("im_select").setup({
                set_default_events = { "VimEnter", "InsertLeave", "CmdlineLeave" },
            })
        end,
    },
madjxatw commented 1 year ago

There is no more terminal spawning occurring, but input method (keyboard) switch still does not work.

    {
        "keaising/im-select.nvim",
        opts = {
          set_default_events = { "VimEnter", "InsertLeave", "CmdlineLeave" },
        }
        config = function(_, opts)
            require("im_select").setup(opts)
        end,
    },
keaising commented 1 year ago

Please follow my instructions.

madjxatw commented 1 year ago

I did it but i didn't work. BTW, both of my config are correct, they work well on Linux.

keaising commented 1 year ago

Please follow this instruction, without modified by yourself: https://github.com/keaising/im-select.nvim/issues/16#issuecomment-1704005154

madjxatw commented 1 year ago

Please follow this instruction, without modified by yourself: #16 (comment)

I said I did the same way but it did not work.

keaising commented 1 year ago

Can not reproduce

keaising commented 12 months ago

There is another user meet similar issue on Windows, but I don't use Windows heavily and I can not reproduce your issue, so I add some doc https://github.com/keaising/im-select.nvim/pull/18 which metioned your issue in README.

If someone can fix your issues on Windows in the future, I will merge their PR.

MasouShizuka commented 9 months ago

Maybe you could try changing this code in im_select.lua:

    if C.async_switch_im then
        vim.fn.jobstart(table.concat(command, " "), { detach = true })
    else
        local jobid = vim.fn.jobstart(table.concat(command, " "), { detach = false })
        vim.fn.jobwait({ jobid }, 200)
    end

to:

    if C.async_switch_im then
        -- vim.fn.jobstart(table.concat(command, " "), { detach = true })
        vim.fn.jobstart(command, { detach = true })
    else
        -- local jobid = vim.fn.jobstart(table.concat(command, " "), { detach = false })
        local jobid = vim.fn.jobstart(command, { detach = false })
        vim.fn.jobwait({ jobid }, 200)
    end

After I did this, im-select.nvim works on windows 11.

MasouShizuka commented 9 months ago

Oh sorry, I found out that the reason I had to change the code to make it work is:

vim.opt.shell = "pwsh -NoLogo"

If comment out the above, im-select.nvim could work without changing the code, but a pop-up window will appear every time I press esc.

keaising commented 7 months ago

@madjxatw Could you please have a try with https://github.com/keaising/im-select.nvim/pull/22 ?

I want to know whether this PR can solve your problem or not.

If you have any question, please comment in https://github.com/keaising/im-select.nvim/pull/22