Update fzf-lua pick_chezmoi to use files picker and chezmoiedit command

- Use `fzf-lua`'s `files` picker to have icons and preview
- Use `vimcd_entry()` to parse picker output
This commit is contained in:
Thomas Vandal 2024-12-29 21:41:49 -05:00
parent 1e83b4f843
commit 692bd4a00e

View file

@ -3,22 +3,12 @@ local pick_chezmoi = function()
require("telescope").extensions.chezmoi.find_files()
elseif LazyVim.pick.picker.name == "fzf" then
local fzf_lua = require("fzf-lua")
local results = require("chezmoi.commands").list()
local chezmoi = require("chezmoi.commands")
local opts = {
fzf_opts = {},
fzf_colors = true,
actions = {
["default"] = function(selected)
chezmoi.edit({
targets = { "~/" .. selected[1] },
args = { "--watch" },
})
end,
},
local actions = {
["enter"] = function(selected)
fzf_lua.actions.vimcmd_entry("ChezmoiEdit", selected, {cwd = os.getenv("HOME")})
end,
}
fzf_lua.fzf_exec(results, opts)
require("fzf-lua").files({ cmd = "chezmoi managed --include=files,symlinks", actions = actions })
elseif LazyVim.pick.picker.name == "snacks" then
local results = require("chezmoi.commands").list({
args = {