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

[Feature request] fzf-lua picker #47

Open
Geobert opened this issue Dec 16, 2024 · 1 comment
Open

[Feature request] fzf-lua picker #47

Geobert opened this issue Dec 16, 2024 · 1 comment

Comments

@Geobert
Copy link

Geobert commented Dec 16, 2024

Hi,

there’s a picker for Telescope but not for fzf-lua yet :)

LazyVim.org seems to lean into using the later as default picker (if telescope is not enabled, it auto enables fzf-lua)

@JBarlowDev
Copy link

JBarlowDev commented Dec 24, 2024

I have something working here as also use fzf-lua and workspaces. Fzf-lua doesn't seem to have a concept of extensions like telescope but can still create custom pickers fairly easily. I took a look at todo-comments.nvim which also provides both a telescope extension and fzf helper.

Based on that I have a simple version working locally:

local M = {}

local workspaces = require("workspaces")
local fzfLua = require("fzf-lua")

function M.workspace_switch()
  local opts = {}
  opts.actions = {
    ['default'] = function(selected)
      workspaces.open(selected[1])
    end
  }
  fzfLua.fzf_exec(function(fzf_cb)
    local workspace_list = workspaces.get()

    for _, workspace in ipairs(workspace_list) do
      fzf_cb(workspace.name)
    end
  end, opts)
end

return M

If it's desired I can clean this up and make a pull request? Otherwise hopefully this super simple example will help others.

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

No branches or pull requests

2 participants