project.nvim icon indicating copy to clipboard operation
project.nvim copied to clipboard

fzf-lua integration

Open evanpurkhiser opened this issue 3 years ago • 3 comments

I see there is a Telescope integration. Would be very cool to also have a fzf-lua select last project integration :)

evanpurkhiser avatar May 27 '22 08:05 evanpurkhiser

This is not my priority, but until it's implemented, feel free to check out the project_nvim API.

ahmedkhalf avatar May 30 '22 23:05 ahmedkhalf

I did this for fzf-lua to browse projects and their files:

local fzf_lua = require("fzf-lua")
vim.keymap.set('n', '\\p',
  function()
    local history = require("project_nvim.utils.history")
    local results = history.get_recent_projects()
    fzf_lua.fzf_exec(results, {
      actions = {
        ['default'] = {
          function(selected)
            fzf_lua.files({ cwd = selected[1] })
          end,
        }
      }
    })
  end,
  { noremap = true, silent = true })

deathmaz avatar Aug 11 '22 14:08 deathmaz

here's an extended version with project deletion:

  local fzf_lua = require("fzf-lua")
  vim.keymap.set('n', '\\p',
    function()
      local history = require("project_nvim.utils.history")
      fzf_lua.fzf_exec(function(cb)
        local results = history.get_recent_projects()
        for _, e in ipairs(results) do
          cb(e)
        end
        cb()
      end,
        {
          actions = {
            ['default'] = {
              function(selected)
                fzf_lua.files({ cwd = selected[1] })
              end,
            },
            ['ctrl-d'] = {
              function(selected)
                history.delete_project({ value = selected[1] })
              end,
              fzf_lua.actions.resume
            }
          }
        })
    end,
    opts)

deathmaz avatar Aug 12 '22 11:08 deathmaz