ahmedkhalf / project.nvim

The superior project management solution for neovim.
Apache License 2.0
1.37k stars 131 forks source link

fzf-lua integration #71

Open evanpurkhiser opened 2 years ago

evanpurkhiser commented 2 years ago

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

ahmedkhalf commented 2 years ago

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

deathmaz commented 2 years ago

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 commented 2 years ago

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)