pick_win cannot open a file when on the dashboard #2103
Replies: 4 comments 6 replies
-
return {
{
"folke/snacks.nvim",
opts = {
picker = {
actions = {
pick_win = function(picker)
if not picker.layout.split then
picker.layout:hide()
end
local win = Snacks.picker.util.pick_win({
main = picker.main,
filter = function()
return true
end,
})
if not win then
if not picker.layout.split then
picker.layout:unhide()
end
return true
end
picker.main = win
if not picker.layout.split then
vim.defer_fn(function()
if not picker.closed then
picker.layout:unhide()
end
end, 100)
end
end,
},
},
},
},
} I believe should do it. By default it ignores filetypes that start with snacks.nvim/lua/snacks/picker/util/init.lua Lines 384 to 386 in bc0630e |
Beta Was this translation helpful? Give feedback.
-
opts = {
picker = {
actions = {
pick_win = function(picker) --[[Override]]
-- https://github.com/folke/snacks.nvim/blob/bc0630e43be5699bb94dadc302c0d21615421d93/lua/snacks/picker/actions.lua#L281-L300
if not picker.layout.split then
picker.layout:hide()
end
local win = Snacks.picker.util.pick_win {
main = picker.main,
float = false, -- vim.api.nvim_win_get_config(win).relative == ''
filter = function(_, buf)
local ft = vim.bo[buf].ft
return ft == 'snacks_dashboard' or not ft:find '^snacks'
end,
}
if not win then
if not picker.layout.split then
picker.layout:unhide()
end
return true
end
picker.main = win
if not picker.layout.split then
vim.defer_fn(function()
if not picker.closed then
picker.layout:unhide()
end
end, 100)
end
end, |
Beta Was this translation helpful? Give feedback.
-
Thanks guys. Is this documented somewhere? I really like snacks.nvim but it seems like a lot of functionality is undocumented or I just can't find it. |
Beta Was this translation helpful? Give feedback.
-
Alright guys, one more request. Coming from neo-tree, hitting enter on a directory in the tree would expand that directory. Hitting enter on a file would present the window picker options. I'm currently using this: list = {
keys = {
["<CR>"] = { { "pick_win", "confirm" } },
...
},
},
This seems to work sometimes and not others. If I only have one pane open, hitting enter on a directory opens it but if I have more than one pane open, I am presented with the pick_win options. This is obviously because pick_win automatically returns the window ID of the only pane if there's only one open. Is there a command I can add before |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I just switched over from neo-tree to snacks.explorer. I've got
pick_win
configured the way I like it I think, but when I first open nvim, I cannot open a file from the explorer while the initial dashboard is visible. Once I open a file using another method, I can use the explorer as expected. Does anyone have a workaround for this?Folke mentioned a way to override the
pick_win
function as well. Can someone explain this? I can't find any documentation on thepick_win
function.Beta Was this translation helpful? Give feedback.
All reactions