Files
LazyVim/lua/lazyvim/plugins/extras/util/project.lua
Folke Lemaitre 39a908c9fa feat(pick): move pickers to extras (telescope still the default) (#3606)
## What is this PR for?

Refactoring of pickers in LazyVim:

- [x] telescope moved to extras
- [x] dressing was moved to the telescope extra. Not needed with fzf-lua
and noice
- [x] when none of the two is enabled, then telescope will be enabled
- [x] when using `:LazyExtras` to enable fzf-lua, the telescope spec
will never be parsed
- [x] when not using `:LazyExras`, the spec will be parsed, but one of
the two will be disabled.
- [x] only one picker extra can be used to prevent issues
- [ ] cleanup lsp keymaps
2024-06-13 06:07:02 +02:00

95 lines
2.1 KiB
Lua

local pick = function()
if LazyVim.pick.picker.name == "telescope" then
return vim.cmd("Telescope projects")
elseif LazyVim.pick.picker.name == "fzf" then
local fzf_lua = require("fzf-lua")
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
end
return {
{
"ahmedkhalf/project.nvim",
opts = {
manual_mode = true,
},
event = "VeryLazy",
config = function(_, opts)
require("project_nvim").setup(opts)
LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("projects")
end)
end,
},
{
"nvim-telescope/telescope.nvim",
optional = true,
keys = {
{ "<leader>fp", pick, desc = "Projects" },
},
},
{
"ibhagwan/fzf-lua",
optional = true,
keys = {
{ "<leader>fp", pick, desc = "Projects" },
},
},
{
"goolord/alpha-nvim",
optional = true,
opts = function(_, dashboard)
local button = dashboard.button("p", "" .. " Projects", pick)
button.opts.hl = "AlphaButtons"
button.opts.hl_shortcut = "AlphaShortcut"
table.insert(dashboard.section.buttons.val, 4, button)
end,
},
{
"echasnovski/mini.starter",
optional = true,
opts = function(_, opts)
local items = {
{
name = "Projects",
action = pick,
section = string.rep(" ", 22) .. "Telescope",
},
}
vim.list_extend(opts.items, items)
end,
},
{
"nvimdev/dashboard-nvim",
optional = true,
opts = function(_, opts)
local projects = {
action = pick,
desc = " Projects",
icon = "",
key = "p",
}
projects.desc = projects.desc .. string.rep(" ", 43 - #projects.desc)
projects.key_format = " %s"
table.insert(opts.config.center, 3, projects)
end,
},
}