AckslD / nvim-anywise-reg.lua

Plugin for making registers content-aware beyond char- and linewise
41 stars 1 forks source link

nvim-tree's "p" is broken #14

Open Gelio opened 3 years ago

Gelio commented 3 years ago

Hey!

I've noticed that after enabling nvim-anywise-reg using the default config (p for anywise-reg's paste), pasting files in nvim-tree stopped working. It looks like anywise-reg overrides the mapping that nvim-tree sets for p

:map p
n  p           *@:lua require'nvim-tree'.on_keypress('paste')<CR>

Do you think we could not set the keybindings only when outside nvim-tree?

Gelio commented 3 years ago

I've noticed that there is also a bit of lag when I press d in nvim-tree now. The mappings that I have:

n  dac         *@<Cmd>lua require("anywise_reg.keybinds").perform_action('', 'd', 'ac')<CR>
n  daf         *@<Cmd>lua require("anywise_reg.keybinds").perform_action('', 'd', 'af')<CR>
n  daW         *@<Cmd>lua require("anywise_reg.keybinds").perform_action('', 'd', 'aW')<CR>
n  daw         *@<Cmd>lua require("anywise_reg.keybinds").perform_action('', 'd', 'aw')<CR>
n  dic         *@<Cmd>lua require("anywise_reg.keybinds").perform_action('', 'd', 'ic')<CR>
n  dif         *@<Cmd>lua require("anywise_reg.keybinds").perform_action('', 'd', 'if')<CR>
n  diW         *@<Cmd>lua require("anywise_reg.keybinds").perform_action('', 'd', 'iW')<CR>
n  diw         *@<Cmd>lua require("anywise_reg.keybinds").perform_action('', 'd', 'iw')<CR>
n  d           *@:lua require'nvim-tree'.on_keypress('remove')<CR>
n  diÞ         * <Nop>
n  daÞ         * <Nop>
n  dÞ          * <Nop>
n  d           * <Cmd>lua require("which-key").show("d", {mode = "n", auto = true})<CR>
n  ds            <Plug>Dsurround

It looks like d mappings should also not be bound in nvim-tree

AckslD commented 3 years ago

@Gelio thanks for reporting this. We could allow the user to specify some filetypes where the plugin should be loaded (can be * for all). What do you think?

Gelio commented 3 years ago

Yeah, that could be a possible solution, although IMO that would limit the usability of the plugin as users would have to manually list many filetypes :thinking:

I'm wondering how does e.g. vim-surround do it - after disabling anywise-reg, I still have a ds mapping from vim-surround:

:map d
n  d           *@:lua require'nvim-tree'.on_keypress('remove')<CR>
n  daÞ         * <Nop>
n  diÞ         * <Nop>
n  dÞ          * <Nop>
n  d           * <Cmd>lua require("which-key").show("d", {mode = "n", auto = true})<CR>
n  ds            <Plug>Dsurround

but does not prevent nvim-tree from running it's d mapping immediately (whereas with anywise-reg there is a lag when vim is waiting for other characters to see if it should do just d or some d-prefixed mapping). The same goes for c - nvim tree does a copy immediately instead of trying to match cs or cS from vim-surround

https://user-images.githubusercontent.com/889383/126136414-39871875-5f81-407e-9f8a-205240bbdf60.mp4

IMO if we can achieve the same functionality as vim-surround, then the problem would be solved without hindering usability/requiring extensive configuration.

I am not a vim plugin expert, so there is little insight I can offer further :slightly_frowning_face:

AckslD commented 3 years ago

Thanks @Gelio! I'll try to understand how this is done in vim-surround :+1: