fix(fzf-lua): set cwd for previewing chezmoi files outside home directory

Used the solution posted by @zjrgov in this gist:
https://github.com/LazyVim/LazyVim/pull/6095#issuecomment-3258889700
This commit is contained in:
Elizer Dolorosa 2025-10-24 10:16:59 +08:00
parent 5098a69870
commit 11725a4590

View file

@ -3,12 +3,13 @@ local pick_chezmoi = function()
require("telescope").extensions.chezmoi.find_files()
elseif LazyVim.pick.picker.name == "fzf" then
local fzf_lua = require("fzf-lua")
local dest_dir = os.getenv("HOME")
local actions = {
["enter"] = function(selected)
fzf_lua.actions.vimcmd_entry("ChezmoiEdit", selected, { cwd = os.getenv("HOME") })
fzf_lua.actions.vimcmd_entry("ChezmoiEdit", selected, { cwd = dest_dir })
end,
}
fzf_lua.files({ cmd = "chezmoi managed --include=files,symlinks", actions = actions, hidden = false })
fzf_lua.files({ cmd = "chezmoi managed --include=files,symlinks", actions = actions, cwd = dest_dir, hidden = false })
elseif LazyVim.pick.picker.name == "snacks" then
local results = require("chezmoi.commands").list({
args = {