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(live_grep): attach mapping is configurable through options #3392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

richardmarbach
Copy link

@richardmarbach richardmarbach commented Dec 29, 2024

Description

I started writing a new picker to improve the refinement of the live_grep picker search results and noticed that all I really wanted to do was add custom attachment_mappings to the existing live_grep picker. It would be nice if the attachment_mappings were configurable instead of needing to create a copy of an existing picker.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I changed my mapping for live grep to use a custom attach_mapping:

local refine_word_action = function(prompt_bufnr)
  require("telescope.actions.generate").refine(prompt_bufnr, {
    prompt_title = "Refine word results",
  })
end

local attach_mappings = function(_, map)
  map("i", "<c-space>", refine_word_action)
  return true
end

vim.keymap.set("<leader>sg", function() require("telescope.builtin").live_grep({ attach_mappings = attach_mappings }) end)

To check:

  1. Execute the mapping, e.g. <leader>sg
  2. search some text to populate the search buffer (e.g. telescope)
  3. press the refinement shortcut (e.g. <c-space>)

The prompt title should now read "Refine word results"

Configuration:

  • Neovim version (nvim --version): NVIM v0.10.3
  • Operating system and version: macOS Sequonia Version 15.1.1

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

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.

1 participant