sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.6k stars 101 forks source link

Default keymaps should use `<LocalLeader>` instead of `<Leader>` #518

Open WieeRd opened 2 weeks ago

WieeRd commented 2 weeks ago

The default keymaps provided by diffview.nvim includes <Leader>e, <Leader>b and <Leader>c. These have a high chance of colliding with the user's config, since <Leader>{key} keymaps are very common. Not a huge problem, it is possible for each user to change the keymaps based on their need. However, Vim always had a native way to prevent this exact problem.

The <LocalLeader>

Simply put, <LocalLeader> is an alternative <Leader> bound to maplocalleader instead of mapleader. It can be set to the same key with <Leader> and actually shares the same default value of backslash \.

The intended purpose of this special key is setting buffer-local keymaps from ftplugins. This avoids overwriting the global keymaps with filetype specific or special buffer specific keymaps.

lazy.nvim uses localleader keymaps inside it's :Lazy dashboard window.

  • Custom key <localleader>l Open lazygit log
  • Custom key <localleader>t Open terminal in plugin dir
  • Custom key <localleader>i Inspect Plugin

I think this would be a better choice for default keymaps used inside diffview.nvim's special windows only. Then, if the user wants to use <Leader> anyway, they can just g:maplocalleader to a same value.