m4xshen / hardtime.nvim

Establish good command workflow and quit bad habit
MIT License
1.38k stars 26 forks source link

Plugin overwrites keymaps of `restricted_keys` #33

Closed Mithrandir2k18 closed 1 year ago

Mithrandir2k18 commented 1 year ago

Describe the bug installing the plugin disables shortcuts for e.g. CTRL+P which opens builtin.git_files in telescope or - is is a bind for oil.nvim. This is how I mainly navigate between files. Hardtime also doesn't give me an error message telling me that that's suboptimal, so I think it may be a bug.

Config options Nothing, I really just added hardtime to lazy as per the readme.

Expected behavior hardtime gives me a hard time but still lets me navigate between files.

Additional context See my dotfiles repo for my neovim config.

m4xshen commented 1 year ago

You can add "oil" and "TelescopePrompt" to disabled_filetypes to disable hardtime.nvim when using these plugins.

Mithrandir2k18 commented 1 year ago

Tried that, the problem is enabling hardtime seems to unbind/rebind some of my binds, like <C-P> for searching the repo or - for oil. Even after disabling it the binds still don't work. It doesn't hurt anything if I set enabled=false in the opts but as soon as I enable it, I need to disable it and restart nvim to reload the binds it overrides.

m4xshen commented 1 year ago

Could you provide your keymap setting of <C-P> and -?

AW3i commented 1 year ago

I have the same issue with the keybindings in oil. This is how I have the keybinding defined in my config vim.keymap.set("n", "-", require("oil").open, { desc = "Open parent directory" })

m4xshen commented 1 year ago

Please try out the latest version of hardtime.nvim. It should work fine now.

AW3i commented 1 year ago

I pulled the latest version and I'm getting the following error now

E5108: Error executing lua: .../aw3i/.local/share/nvim/lazy/oil.nvim/lua/oil/init.lua:379: Vim:E565: Not allowed to change text or change window                                                              
stack traceback:                                                                                                                                                                                                
        [C]: in function 'edit'                                                                                                                                                                                 
        .../aw3i/.local/share/nvim/lazy/oil.nvim/lua/oil/init.lua:379: in function 'callback'                                                                                                                 
        ...ocal/share/nvim/lazy/hardtime.nvim/lua/hardtime/init.lua:15: in function <...ocal/share/nvim/lazy/hardtime.nvim/lua/hardtime/init.lua:11>  
m4xshen commented 1 year ago

@AW3i are you using lazy.nvim to install plugins? If yes, please set the keymap in the keys section when installing oil.nvim:

{
      "stevearc/oil.nvim",
      dependencies = { "nvim-tree/nvim-web-devicons" },
      opts = {},
      keys = {
         { "-", ":lua require('oil').open()<CR>" },
      },
}
AW3i commented 1 year ago

Using the keys section makes it work, thanks!

Mithrandir2k18 commented 1 year ago

@AW3i are you using lazy.nvim to install plugins? If yes, please set the keymap in the keys section when installing oil.nvim:

{
      "stevearc/oil.nvim",
      dependencies = { "nvim-tree/nvim-web-devicons" },
      opts = {},
      keys = {
         { "-", ":lua require('oil').open()<CR>" },
      },
}

What's the difference between setting it in the plugins map vs. setting the keymap separately?

m4xshen commented 1 year ago

Putting it inside keys makes sure that the keymap is set after the plugin is loaded.