m4xshen / hardtime.nvim

Establish good command workflow and quit bad habit
MIT License
1.49k stars 25 forks source link

Plugin's injected keymaps are interfering with those of other plugins #98

Closed PrayagS closed 5 months ago

PrayagS commented 5 months ago

Describe the bug

This is happening particularly for angle brackets (>, <). I understand that hardtime will create keymaps for all the usual keys to record/disable them. It is doing the same with angle brackets as well. However, my other keymaps that use angle brackets like >p and <p stop working when I enable hardtime.

Config options

{
    "m4xshen/hardtime.nvim",
    dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" },
    opts = {
        max_count = 5,
        allow_different_key = true,
        restriction_mode = "hint",
    }
},

To Reproduce Steps to reproduce the behavior:

  1. Enable hardtime.
  2. Add any other keymap that uses angle brackets.
  3. Check verbose map (:verbose map >).
    n  >iÞ         * <Nop>
        Last set from ~/.local/share/nvim/lazy/which-key.nvim/lua/which-key/keys.lua line 201
    n  >i          * <Cmd>lua require("which-key").show(">i", {mode = "n", auto = true})<CR>
        Last set from ~/.local/share/nvim/lazy/which-key.nvim/lua/which-key/keys.lua line 201
    n  >aÞ         * <Nop>
        Last set from ~/.local/share/nvim/lazy/which-key.nvim/lua/which-key/keys.lua line 201
    n  >a          * <Cmd>lua require("which-key").show(">a", {mode = "n", auto = true})<CR>
        Last set from ~/.local/share/nvim/lazy/which-key.nvim/lua/which-key/keys.lua line 201
    n  >           * <Lua 642: ~/.local/share/nvim/lazy/hardtime.nvim/lua/hardtime/init.lua:138>
        Last set from ~/.local/share/nvim/lazy/hardtime.nvim/lua/hardtime/init.lua line 138
    v  >           * >gv
        Last set from ~/dev/dotfiles/config/nvim/lua/mappings.lua line 78
    n  >P          * <Plug>(YankyPutIndentBeforeShiftRight)
        Last set from ~/dev/dotfiles/config/nvim/after/plugin/editor.lua line 28
    n  >p          * <Plug>(YankyPutIndentAfterShiftRight)
        Last set from ~/dev/dotfiles/config/nvim/after/plugin/editor.lua line 26
  4. The plugin keybindings >p and >P don't work.

What all have I tried

It works when I disable hardtime (all other plugins and mappings are enabled).

m4xshen commented 5 months ago

You can remove those keys from hardtime's config:

opts = {
  resetting_keys = {
    [">"] = {},
    ["<"] = {},
  },
}
PrayagS commented 5 months ago

Thanks a lot! This did the trick.

I was playing with the restricted_keys option but that wasn't working because I had the wrong idea of what that option means.