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

Repeat mappings: leap backward will suddenly only leap forward #202

Open
teocns opened this issue Feb 3, 2024 · 8 comments
Open

Repeat mappings: leap backward will suddenly only leap forward #202

teocns opened this issue Feb 3, 2024 · 8 comments

Comments

@teocns
Copy link

teocns commented Feb 3, 2024

Repeat mappings are bound to Enter and Shift-Enter and work as expected, however Shift-Enter will stop working (under mysterious circumstances) and behave like Enter, the forward movement.

It usually occurs after intensive buffer / window / tab switching, and will never regain functionality on any buffer unless restarting vim.

Any ideas what could be causing this? Any debugging logs you recommend

{
  "ggandor/leap.nvim",
  keys = {
    { "s", mode = { "n", "x", "o" }, desc = "Leap forward to" },
    { "S", mode = { "n", "x", "o" }, desc = "Leap backward to" },
    { "gs", mode = { "n", "x", "o" }, desc = "Leap from windows" },
  },
  config = function(_, opts)
    local leap = require "leap"
    for k, v in pairs(opts) do
      leap.opts[k] = v
    end
    leap.add_default_mappings()
    require("leap").add_repeat_mappings("<enter>", "<s-enter>", {
      relative_directions = true,
      modes = { "n", "x", "o" },
    })
    vim.keymap.del({ "x", "o" }, "x")
    vim.keymap.del({ "x", "o" }, "X")
  end,
}

Output of Redir map <s-enter> after the functionality broke:

o  <S-CR>      * <Lua 2085: ~/.local/share/nvim/lazy/leap.nvim/lua/leap/user.lua:59>
                 Repeat leap in opposite direction
x  <S-CR>      * <Lua 2084: ~/.local/share/nvim/lazy/leap.nvim/lua/leap/user.lua:59>
                 Repeat leap in opposite direction
n  <S-CR>      * <Lua 2083: ~/.local/share/nvim/lazy/leap.nvim/lua/leap/user.lua:59>
                 Repeat leap in opposite direction
@ggandor
Copy link
Owner

ggandor commented Feb 4, 2024

Lazy's keys can cause problems (#191), and it's unnecessary, Leap lazy-loads itself, so as a very first step, I'd remove that from the config.

@teocns
Copy link
Author

teocns commented Feb 6, 2024

Lazy's keys can cause problems (#191), and it's unnecessary, Leap lazy-loads itself, so as a very first step, I'd remove that from the config.

Will give a try with event = "VeryLazy", though this slightly increases startup time. Keep you posted

@teocns
Copy link
Author

teocns commented Feb 16, 2024

Hey @ggandor! Seems that did not change much, the issue persists occasionally and I still could not figure the cause.

One important note: once the issue presents, doesn't matter the direction (bk/fwd), repeating the leap motion in the opposite direction won't work.

Repeating the motion does work; just not in the right direction

For example, I could be leaping forward s{a}{b} <CR> <CR> and then intend to return at the starting position with <S-CR> <S-CR>: under the buggy circumstance it will leap forward twice instead. A fresh motion with S{a}{b} <CR> will begin leaping backwards, but <S-CR> won't leap forward instead, as you'd expect. The functionality is permanently disrupted and restarting neovim is inevitable at this point.

Pasting here current configuration of what I suspect might be interfering.

nvim-surround
{
    "kylechui/nvim-surround",
    event = "VeryLazy",
    config = function() require("nvim-surround").setup {} end,
    -- Commented them out as suggested | nothing has changed
    -- keys = {
    -- { "cs",desc = "Change surrounding" },
    -- { "ds",desc = "Delete surrounding" },
    -- { "ys", mode = { "n", "x", "o" }, desc = "Add surrounding", noremap = true, nowait = true },
    -- { "cs",desc = "Change surrounding" },
    -- { "ds",desc = "Delete surrounding" },
    -- { "ys",desc = "Add surrounding" },
    -- },
  }
leap.nvim
{
    "ggandor/leap.nvim",
    event = "VeryLazy",
    config = function(_, opts)
      local leap = require "leap"
      for k, v in pairs(opts) do -- brogramerr
        leap.opts[k] = v
      end
      leap.add_default_mappings()
      require("leap").add_repeat_mappings("<enter>", "<s-enter>", {
        -- False by default. If set to true, the keys will work like the
        -- native semicolon/comma, i.e., forward/backward is understood in
        -- relation to the last motion.
        relative_directions = true,
        -- By default, all modes are included.
        modes = { "n", "x", "o" },
      })
      vim.keymap.del({ "x", "o" }, "x")
      vim.keymap.del({ "x", "o" }, "X")
    end,
  }

which-key: require("which-key.health").check()
WhichKey: checking conflicting keymaps ~
- WARNING conflicting keymap exists for mode **"n"**, lhs: **" w"**
- rhs: ` `
- WARNING conflicting keymap exists for mode **"n"**, lhs: **" a"**
- rhs: ` `
- WARNING conflicting keymap exists for mode **"n"**, lhs: **" q"**
- rhs: ` `
- WARNING conflicting keymap exists for mode **"n"**, lhs: **" s"**
- rhs: ` `
- WARNING conflicting keymap exists for mode **"n"**, lhs: **" uf"**
- rhs: ` `
- WARNING conflicting keymap exists for mode **"n"**, lhs: **"ys"**
- rhs: `<Plug>(nvim-surround-normal)`
- WARNING conflicting keymap exists for mode **"n"**, lhs: **"yS"**
- rhs: `<Plug>(nvim-surround-normal-line)`
- WARNING conflicting keymap exists for mode **"n"**, lhs: **"t"**
- rhs: ` `
- WARNING conflicting keymap exists for mode **"n"**, lhs: **"M"**
- rhs: ` `

@ggandor
Copy link
Owner

ggandor commented Feb 17, 2024

Okay, next one: use set_repeat_keys instead of add_repeat_mappings (the latter is deprecated, and the former is heavily refactored, doesn't use autocommands at all, so there is some chance it will fix the bug). (Btw add_default_mappings is also deprecated, but that's irrelevant for now.)

Also, what are your settings for opts.special_keys?

@teocns
Copy link
Author

teocns commented Feb 18, 2024

Seems it started working with the porposed changed, at least for now! I haven't touched opts.special_keys so it has to be defualt.

Thanks!

@teocns teocns closed this as completed Feb 18, 2024
@teocns teocns reopened this Feb 18, 2024
@teocns
Copy link
Author

teocns commented Feb 18, 2024

Sorry, unfortunately after further usage I've found out that the issue still occurs. What additional info could help you narrow down the scope of the issue?

@teocns teocns closed this as completed Feb 18, 2024
@teocns teocns reopened this Feb 18, 2024
@teocns
Copy link
Author

teocns commented Mar 18, 2024

@ggandor do we have any news on this?

@ggandor
Copy link
Owner

ggandor commented Mar 24, 2024

I cannot reproduce, and I have no further idea about what could be the cause. My hunch is that this is not a Leap problem, but Shift-Enter is somehow not recognized anymore as separate from Enter. It's simple to confirm this, try another key (like backspace) for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants