feat(snacks.picker): added alt-c to toggle between cwd/root dir

This commit is contained in:
Folke Lemaitre 2025-01-20 20:21:23 +01:00
parent dc8512fce1
commit 6be7c4fee4
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -27,11 +27,32 @@ end
return { return {
desc = "Fast and modern file picker", desc = "Fast and modern file picker",
-- recommended = true, recommended = true,
{ {
"folke/snacks.nvim", "folke/snacks.nvim",
opts = { opts = {
picker = {}, picker = {
win = {
input = {
keys = {
["<a-c>"] = {
"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 -- stylua: ignore
keys = { keys = {