diff --git a/lua/lazyvim/plugins/extras/editor/snacks_picker.lua b/lua/lazyvim/plugins/extras/editor/snacks_picker.lua index e286dff3..2b623179 100644 --- a/lua/lazyvim/plugins/extras/editor/snacks_picker.lua +++ b/lua/lazyvim/plugins/extras/editor/snacks_picker.lua @@ -27,11 +27,32 @@ end return { desc = "Fast and modern file picker", - -- recommended = true, + recommended = true, { "folke/snacks.nvim", opts = { - picker = {}, + picker = { + win = { + input = { + keys = { + [""] = { + "toggle_cwd", + mode = { "n", "i" }, + }, + }, + }, + }, + actions = { + ---@param p snacks.Picker + toggle_cwd = function(p) + local root = LazyVim.root({ buf = p.input.filter.current_buf, normalize = true }) + local cwd = vim.fs.normalize((vim.uv or vim.loop).cwd() or ".") + local current = p:cwd() + p:set_cwd(current == root and cwd or root) + p:find() + end, + }, + }, }, -- stylua: ignore keys = {