Closed lovelock closed 6 months ago
我仔细分析了一下,发现启动之后这个插件并没有加载,再想想这个Astronvim的哲学,就是不需要的不加载,那么怎么让它不lazy load呢?就是在相关的配置里加上lazy = false
,所以最终改成这样就好了
return {
{
"keaising/im-select.nvim",
lazy = false, -- 最关键的在这里
config = function()
require("im_select").setup {
-- IM will be set to `default_im_select` in `normal` mode
-- For Windows/WSL, default: "1033", aka: English US Keyboard
-- For macOS, default: "com.apple.keylayout.ABC", aka: US
-- For Linux, default:
-- "keyboard-us" for Fcitx5
-- "1" for Fcitx
-- "xkb:us::eng" for ibus
-- You can use `im-select` or `fcitx5-remote -n` to get the IM's name
default_im_select = "com.apple.keylayout.ABC",
-- Can be binary's name or binary's full path,
-- e.g. 'im-select' or '/usr/local/bin/im-select'
-- For Windows/WSL, default: "im-select.exe"
-- For macOS, default: "im-select"
-- For Linux, default: "fcitx5-remote" or "fcitx-remote" or "ibus"
default_command = "im-select",
-- Restore the default input method state when the following events are triggered
set_default_events = { "VimEnter", "FocusGained", "InsertLeave", "CmdlineLeave" },
-- Restore the previous used input method state when the following events
-- are triggered, if you don't want to restore previous used im in Insert mode,
-- e.g. deprecated `disable_auto_restore = 1`, just let it empty
-- as `set_previous_events = {}`
set_previous_events = { "InsertEnter" },
-- Show notification about how to install executable binary when binary missed
keep_quiet_on_no_binary = false,
-- Async run `default_command` to switch IM or not
async_switch_im = true,
}
end,
},
}
For anyone come here in the future:
If you use Astronvim/LazyVim or some else neovim distribution and im-select.nvim does not work, you can have a try with option:
{
"keaising/im-select.nvim",
lazy = false, -- This is the key
config = function()
require("im_select").setup({})
end,
}
im-select com.apple.keylayout.ABC
能正常切换~/.config/nvim/lua/user/plugins/
里创建了im-select.lua
文件,内容如下配置之后的效果就是切换到Normal模式下,再输入还是中文,比如按两下J,会进行中文输入,然后按下Shift(我的squirrel配置的中英文切换),会切换到英文模式,并且光标往前移动了2个。
反复实验多次,参数也改了几次,都不生效,就像没有配置这个一样。我平时用squirrel比较多,但即使用原生的输入法也不行,感觉是这里面配置的事件没有被触发,但又不知道怎么调试。多谢!