From 03c3089787bf4c013ea79f9b75f3b8b905b5e667 Mon Sep 17 00:00:00 2001 From: gogamid <36050790+gogamid@users.noreply.github.com> Date: Sat, 18 Jan 2025 11:38:37 +0100 Subject: [PATCH] feat(chezmoi): add snacks picker integration for chezmoi files --- lua/lazyvim/plugins/extras/util/chezmoi.lua | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lua/lazyvim/plugins/extras/util/chezmoi.lua b/lua/lazyvim/plugins/extras/util/chezmoi.lua index 633f3008..4adc54f8 100644 --- a/lua/lazyvim/plugins/extras/util/chezmoi.lua +++ b/lua/lazyvim/plugins/extras/util/chezmoi.lua @@ -19,6 +19,42 @@ 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 i, czFile in ipairs(results) do + table.insert(items, { + idx = i, + score = i, + text = czFile, + name = czFile, + file = czFile, + }) + end + + ---@type snacks.picker.Config + local opts = { + items = items, + format = "filename", + confirm = function(_, item) + -- picker:close() + require("chezmoi.commands").edit({ + targets = { item.text }, + args = { "--watch" }, + }) + end, + } + Snacks.picker.pick(opts) end end