feat(chezmoi): add snacks picker integration for chezmoi files (#5429)

## Description

We have a new picker Snacks picker, it means telescope and fzf-lua can
be uninstalled. But chezmoi files still listed only with telescope and
fzf-lua. In this pr we add snacks.picker integration if the user has
chosen snacks.picker in the LazyVimExtras.
This commit is contained in:
Imron Gamidli 2025-01-18 14:52:25 +01:00 committed by GitHub
parent b574f01af7
commit 970d1a05da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,6 +19,38 @@ local pick_chezmoi = function()
},
}
fzf_lua.fzf_exec(results, opts)
elseif LazyVim.pick.picker.name == "snacks" then
local results = require("chezmoi.commands").list({
args = {
"--path-style",
"absolute",
"--include",
"files",
"--exclude",
"externals",
},
})
local items = {}
for _, czFile in ipairs(results) do
table.insert(items, {
text = czFile,
file = czFile,
})
end
---@type snacks.picker.Config
local opts = {
items = items,
confirm = function(picker, item)
picker:close()
require("chezmoi.commands").edit({
targets = { item.text },
args = { "--watch" },
})
end,
}
Snacks.picker.pick(opts)
end
end