Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: i_ctrl-o mappings not executed, chars are inserted instead #827

Closed
4 tasks done
bmesot opened this issue Aug 21, 2024 · 5 comments · May be fixed by #879
Closed
4 tasks done

bug: i_ctrl-o mappings not executed, chars are inserted instead #827

bmesot opened this issue Aug 21, 2024 · 5 comments · May be fixed by #879
Labels
bug Something isn't working stale

Comments

@bmesot
Copy link

bmesot commented Aug 21, 2024

Did you check docs and existing issues?

  • I have read all the which-key.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of which-key.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.10.0

Operating system/version

Debian GNU/Linux trixie/sid

Describe the bug

This issue is a remake of issue 141. The mapping chars are inserted in the buffer instead of being processed in normal mode.

I managed to fix the problem by applying the following patch.

diff --git a/lua/which-key/state.lua b/lua/which-key/state.lua
index 83ffd71..d6f8edf 100644
--- a/lua/which-key/state.lua
+++ b/lua/which-key/state.lua
@@ -234,6 +234,12 @@ function M.execute(state, key, node)
     if vim.v.register ~= Util.reg() and state.mode.mode ~= "i" and state.mode.mode ~= "c" then
       keystr = '"' .. vim.v.register .. keystr
     end
+
+    local curr_mode = vim.api.nvim_get_mode().mode
+
+    if curr_mode:find("ni[IRV]") ~= nil then
+      keystr = "<C-O>" .. keystr
+    end
   end
   Util.debug("feedkeys", tostring(state.mode), keystr)
   local feed = vim.api.nvim_replace_termcodes(keystr, true, true, true)

Steps To Reproduce

  1. Open a buffer and enter insert mode (i).
  2. Press <c-o> followed by zz.
  3. zz is written in the buffer.

Expected Behavior

  1. zz is executed as a mapping in normal mode.

Health

which-key: require("which-key.health").check()

- OK Most of these checks are for informational purposes only.
  WARNINGS should be treated as a warning, and don't necessarily indicate a problem with your config.
  Please |DON't| report these warnings as an issue.

Checking your config ~
- WARNING |mini.icons| is not installed
- WARNING |nvim-web-devicons| is not installed
- WARNING Keymap icon support will be limited.

Checking for issues with your mappings ~
- OK No issues reported

checking for overlapping keymaps ~
- WARNING In mode `n`, <gc> overlaps with <gcc>:
  - <gc>: Toggle comment
  - <gcc>: Toggle comment line
- OK Overlapping keymaps are only reported for informational purposes.
  This doesn't necessarily mean there is a problem with your config.

Checking for duplicate mappings ~
- OK No duplicate mappings found

Log

Debug Started for v3.13.2
{
  branch = "main",
  commit = "6c1584eb76b55629702716995cca4ae2798a9cca"
}
new Mode(n:1)
Trigger(add) Mode(n:1) ' ` " z= g' g` ] [ <C-W> z g
on_key: i
ModeChanged(n:i)
  new Mode(i:1)
  Safe(true)
Trigger(add) Mode(i:1) <C-R>
on_key: <C-O>
ModeChanged(i:niI)
  Safe(true)
on_key: z
State(start): Mode(n:0) Node(z) { keys = "z" }
  update Mode(n:1)
  continue: z Mode(n:1)
  getchar
  on_key: z
  got: z
  suspend: Mode(n:1)
  Trigger(del) Mode(n:1) z= g' g` ] [ <C-W> z ' ` " g
  feedkeys: Mode(n:1) zz
ModeChanged(niI:i)
  Unsafe(pending "z")
  suspend: Mode(i:1)
  Trigger(del) Mode(i:1) <C-R>
on_key: z
on_key: z
Trigger(add) Mode(n:1) ' ` " z= g' g` ] [ <C-W> z g
Trigger(add) Mode(i:1) <C-R>
on_key: <Esc>
ModeChanged(i:n)
  Safe(true)
on_key: :
ModeChanged(n:c)
  new Mode(c:1)
  Safe(true)
Trigger(add) Mode(c:1) <C-R>
on_key: q
on_key: !
on_key: <CR>
ModeChanged(c:n)
  Unsafe(command-mode)
  suspend: Mode(n:1)
  Trigger(del) Mode(n:1) z= g' g` ] [ <C-W> z ' ` " g
Trigger(add) Mode(n:1) ' ` " z= g' g` ] [ <C-W> z g

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/which-key.nvim", opts = {} },
    -- add any other plugins here
  },
})
@bmesot bmesot added the bug Something isn't working label Aug 21, 2024
@blueberry-zero
Copy link

Ran into the same issue.

You can implement a work around with the following mapping.

vim.keymap.set("i", "<YOUR_BINDING_HERE>", function()
    vim.cmd("startinsert!")
    vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, true, true), 'n', false) 
end, { expr = true })

Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Sep 26, 2024
@EdwinRy
Copy link

EdwinRy commented Sep 30, 2024

I ran into the same issue, the issue patch fixed the problem for me.

@github-actions github-actions bot removed the stale label Oct 1, 2024
Copy link
Contributor

github-actions bot commented Nov 1, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

Copy link
Contributor

github-actions bot commented Nov 9, 2024

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants