Skip to content

Changing nvim settings when IM is active? #40

@davinosuke

Description

@davinosuke

I'm not sure if this is something that can be done already, or if it needs some new feature added. I want to be able to modify or toggle nvim settings when the IM mode changes.

In my neovim config have an autocommand to exit insert mode automatically after 20 seconds of inactivity. It works by changing the updatetime option when entering or exiting insert mode.

When working directly on English text this is fine, but when I use my Japanese IME (fcitx5/mozc) it sometimes exits when I am still typing. Sometimes it takes me a while to find the kanji I need in the dropdown, and that use is not detected as activity by CursorHoldI.

What I think I should do then, is increase or disable the timeout when the IME is active; either directly through the plugin, or by somehow detecting the setting in the autocommand. Increasing updatetime to 10000 or so would probably do the job.

However, I do not know how to do either of these, so any assistance would be welcome. Thanks.

This is the autogroup I am using:

vim.api.nvim_create_augroup("exitinsert", { clear = true })
api.nvim_create_autocmd( {'CursorHoldI'}, {
    group = "exitinsert",
    callback = function()
        vim.cmd.stopinsert()
    end,
})
api.nvim_create_autocmd( {'InsertEnter'}, {
    group = "exitinsert",
    callback = function()
        restore_updatetime = vim.o.updatetime
        vim.o.updatetime = 20000
    end,
})
api.nvim_create_autocmd( {'InsertLeave'}, {
    group = "exitinsert",
    callback = function()
      vim.o.updatetime = restore_updatetime
    end,
})

And my im-select configuration.:

config = function()
    require("im_select").setup({
        default_im_select  = "keyboard-jp-OADG109A",
        default_command = "fcitx5-remote",
    })
end,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions