m4xshen / hardtime.nvim

Establish good command workflow and quit bad habit
MIT License
1.35k stars 27 forks source link

Can't disable restriction for C-N, C-P #96

Closed elderkeltir closed 3 months ago

elderkeltir commented 3 months ago

Describe the bug Cheers! I have a problem with removing C-N and C-P from the restricted keys. It doesn't work as expected (by me)

Config options I copy pasted default config table and simply removed C-N and C-P from the list pastebin

To Reproduce Steps to reproduce the behavior:

  1. have the following remaps: vim.keymap.set("n", "<C-n>", "<cmd>cnext<CR>zz") vim.keymap.set("n", "<C-p>", "<cmd>cprev<CR>zz")
  2. Go to config file for hardtime (e.g. hardtime.lua)
  3. Remove C-N and C-P from the list of restricted_keys
  4. Reload nvim, open telescope live grep window? type something, click C-Q to create qf window from the results.
  5. Spam C-N and see it's blocked after couple clicks

Expected behavior C-N and C-P should be removed from restricted keys, I should be able to navigate fast in qf window

Screenshots none

Additional context I can change value for say restriction_mode and it works after nvim reload, so config is applied.

m4xshen commented 3 months ago

Hi, the way you config is wrong. To remove <C-N> and <C-P> from restricted_keys you can simply set this:

 restricted_keys = {
    ["<C-N>"] = {},
    ["<C-P>"] = {},
 },

This is documented in README:

If the option is a table with a key = value pair, your value will overwrite the default if the key exists, and the pair will be appended to the default configuration if the key doesn't exist. You can set key = {} to remove the default key-value pair.

This approach make sure user don't have to copy paste all the default config just to make a little change!

elderkeltir commented 3 months ago

Yep, I didn't understand that part, thnx for clarification! now it works.