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

implement filter for keymaps #2462

Merged
merged 2 commits into from
May 24, 2023
Merged

implement filter for keymaps #2462

merged 2 commits into from
May 24, 2023

Conversation

bn-peters
Copy link
Contributor

@bn-peters bn-peters commented Apr 10, 2023

Description

There was a todo for more flexible filtering in builtin.keymaps (

-- TODO: make filtering include the mapping and the action
). I implemented this by adding another filter option accepting a keymap as its argument.

I wanted to use this to only filter keymaps with a desc. While this could be a separate flag, I feel like this is cleaner. lhs_filter is now somewhat redundant.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Setup a keymap with a description, and select it:

vim.keymap.set("n", "abc", "<CR>", { desc = "do something" })
vim.keymap.set("n", "def", "<CR>", { desc = "do something else" })
vim.keymap.set("n", "xyz", function()
                               require("telescope.builtin").keymaps({ 
                                   filter = function(keymap)
                                       return keymap.desc and keymap.desc ~= "Nvim builtin"
                                   end,
                               })
                           end)

Configuration:

  • Neovim version (nvim --version):
    NVIM v0.10.0-dev-41b7586
    Build type: Release
    LuaJIT 2.1.0-beta3
    
       system vimrc file: "$VIM/sysinit.vim"
      fall-back for $VIM: "/usr/local/share/nvim"
    

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)

@Conni2461
Copy link
Member

thanks :)

@Conni2461 Conni2461 merged commit 5b7cedd into nvim-telescope:master May 24, 2023
abelmul pushed a commit to abelmul/telescope.nvim that referenced this pull request Jun 6, 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