sindrets / diffview.nvim

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

feat: Allow hiding mappings from the help panel #278

Closed fjchen7 closed 1 year ago

sindrets commented 1 year ago

@fjchen7 Thanks for the PR!

I'm missing some explanation for this change. What's the point of hiding entries from the help panel?

fjchen7 commented 1 year ago

The final purpose is to make help panel cleaner if users want.

For me the specific requirement is:

require("diffview").setup {
  keymaps = {
    file_panel = {
      -- I don't want to show some conventional keymaps
      { "n", "j", actions.next_entry, { desc = false } },
      { "n", "<down>", actions.next_entry, { desc = false } },
      { "n", "k", actions.prev_entry, { desc = false } },
      { "n", "<up>", actions.prev_entry, { desc = false } },

      -- I want to disable some keymaps without showing them in the help panel.
      { "n", "<C-o>", "", { desc = false } },  -- Avoid accidentally messing up buffer
      { "n", "<C-i>", "", { desc = false } },
    }
  }
}
fjchen7 commented 1 year ago

Of we directly choose the special string like __DIFFVIEW_IGNORED__ or something to hide keymap? (Just like which_key_ignore in which-key)

For example,

{ "n", "<2-LeftMouse>", actions.select_entry, { desc = "__DIFFVIEW_IGNORED__" } },

In my opinion, this could avoid conflict with the extension about desc = false in nvim_set_keymap() and may be better.

sindrets commented 1 year ago

@fjchen7 good call. Let's just go with "diffview_ignore" as the special value then.