mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 08:35:53 +02:00
feat(snacks.picker): added alt-c to toggle between cwd/root dir
This commit is contained in:
parent
dc8512fce1
commit
6be7c4fee4
1 changed files with 23 additions and 2 deletions
|
@ -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 = {
|
||||
["<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
|
||||
keys = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue