project.nvim
project.nvim copied to clipboard
Provide fzf-lua integration
Hi @ahmedkhalf, thanks a lot for your work on project.nvim!
I created a fzf-lua integration for myself, maybe you'd like to offer it out of the box.
Snippet from my config:
vim.keymap.set("n", "<leader>fp", function()
local contents = require("project_nvim").get_recent_projects()
local reverse = {}
for i = #contents, 1, -1 do
reverse[#reverse + 1] = contents[i]
end
require("fzf-lua").fzf_exec(reverse, {
actions = {
["default"] = function(e)
vim.cmd.cd(e[1])
end,
["ctrl-d"] = function(x)
local choice = vim.fn.confirm("Delete '" .. #x .. "' projects? ", "&Yes\n&No", 2)
if choice == 1 then
local history = require("project_nvim.utils.history")
for _, v in ipairs(x) do
history.delete_project(v)
end
end
end,
},
})
end, { silent = true, desc = "Switch project" })
I intentionally don't trigger an immediate "find files" as you do with the telescope plugin, as that's not always what I want to do next. It could be improved by printing the paths in a nicer way (<dirname>: <fullpath>), didn't get to that yet.