Skip to content

How to add action to reload fzf with different input? #1459

Answered by ibhagwan
kevinlam03 asked this question in Q&A
Discussion options

You must be logged in to vote

The reason this happens is because ctrl-m is the same as enter (try it in the shell), similarly ctrl-i is tab, etc, switching to a different bind that doesn’t conflict will work, e.g. ctrl-g.

Btw, I would also add F1 help string (desc) and header hint:

vim.keymap.set("n", "<leader>gg", function()
  fzf.files({
    actions = {
      ["enter"] = fzf.actions.file_edit,
      ["ctrl-g"] = {
        desc = "switch-to-git",
        header = "Switch to git",
        fn = function()
          fzf.fzf_exec("git ls-files -m; git diff --name-only --staged", {
            actions = {
              ['enter'] = fzf.actions.file_edit,
            }
          })
        end,
      },
    }
  })
end)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@kevinlam03
Comment options

@ibhagwan
Comment options

Answer selected by kevinlam03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants