Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom text for mappings in help window #1186

Merged
merged 4 commits into from
Oct 19, 2023

Conversation

coffebar
Copy link
Contributor

With this feature, you can add labels for custom mappings (lua functions).

Example mapping with text:

["<c-f>"] = {
  function(state)
     require("telescope.builtin").live_grep({ cwd = context_dir(state) })
  end,
  config = { text = "live grep" }, -- text here
},

Demo

Before

before

After

after

@cseickel
Copy link
Contributor

Cool, I don't believe I never thought of this before!

I would say that it unnecessary to add a nested config object as the mapping is already a config object. I would also prefer the term label over text.

I would change it to:

["<c-f>"] = {
  function(state)
     require("telescope.builtin").live_grep({ cwd = context_dir(state) })
  end,
  label = "live grep",
},

@coffebar
Copy link
Contributor Author

Changed label over text. I thought so, too.

["<c-f>"] = {
  function(state)
     require("telescope.builtin").live_grep({ cwd = context_dir(state) })
  end,
  label = "live grep",
},

Will work now

Copy link
Contributor

@cseickel cseickel left a comment

Choose a reason for hiding this comment

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

Looks good, but I just realized there are no docs included so no one will ever even know this is possible! Can you add some docs?

@coffebar
Copy link
Contributor Author

Sure, it's been added to the documentation. I believe it should also be added to the 'wiki/Recipes,' but only after this feature has been merged. Not to mislead users.

@cseickel cseickel merged commit c49cd5e into nvim-neo-tree:main Oct 19, 2023
2 checks passed
@mehalter
Copy link
Contributor

Ah, I wish I caught this earlier, would desc be a better key for this to align with the keymap.set API? Could add it as an also supported key to avoid a breaking change

@coffebar
Copy link
Contributor Author

coffebar commented Oct 19, 2023

Ah, I wish I caught this earlier, would desc be a better key for this to align with the keymap.set API? Could add it as an also supported key to avoid a breaking change

I don't mind replacing with a breaking change. It's unlikely that anyone but me is already using it.

Just create a new PR

@mehalter
Copy link
Contributor

Thanks @coffebar ! Just opened a PR. Let me know if I need to adjust anything. It might also not be considered a breaking change if it hasn't made it into a release yet.

@cseickel
Copy link
Contributor

It might also not be considered a breaking change if it hasn't made it into a release yet.

That's how I see it.

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.

None yet

3 participants