Skip to content

Conversation

@fjchen7
Copy link
Contributor

@fjchen7 fjchen7 commented Dec 30, 2022

No description provided.

@sindrets
Copy link
Owner

@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
Copy link
Contributor Author

fjchen7 commented Dec 30, 2022

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 fjchen7 requested a review from sindrets January 3, 2023 13:41
Copy link
Owner

@sindrets sindrets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the desc field to anything other than a string is unintended usage of the nvim_set_keymap() API. While it seems to have no side effects right now; there's no guarantee it will stay that way in the future. We need to do this properly and special-case this behavior in the plugin's keymap processing.

You can check here whether the desc field has been set to false, and if so, change the value of the expanded mapping to __DIFFVIEW_IGNORED__ or something.

@fjchen7
Copy link
Contributor Author

fjchen7 commented Jan 5, 2023

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
Copy link
Owner

sindrets commented Jan 5, 2023

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

@fjchen7 fjchen7 requested a review from sindrets January 8, 2023 04:11
Copy link
Owner

@sindrets sindrets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sindrets sindrets changed the title feat: support ignoring mapping in help panel feat: Allow hiding mappings from the help panel Jan 8, 2023
@sindrets sindrets merged commit e45aaf8 into sindrets:main Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants