Ungroup directories in explorer #2051
Unanswered
BluewyDiamond
asked this question in
Q&A
Replies: 2 comments 4 replies
-
What? This? |
Beta Was this translation helpful? Give feedback.
4 replies
-
vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system 'curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua')()
---@module 'snacks'
vim.keymap.set('n', '\\', function()
Snacks.picker.explorer()
end)
require('lazy.minit').repro {
spec = {
{
'folke/snacks.nvim',
---@type snacks.Config
opts = {
picker = {
sources = {
explorer = {
follow_file = false,
finder = function(opts, ctx)
vim.schedule(function()
if not ctx.picker.shown then
ctx.picker:action 'explorer_close_all'
end
end)
return require('snacks.picker.source.explorer').explorer(opts, ctx)
end,
--
actions = {
list_prev = function(picker, item) --[[Override]]
if item.dir then
picker.state = vim.tbl_extend('keep', picker.state or {}, { up_stack = {} })
table.insert(picker.state.up_stack, picker:cwd())
local parent = vim.fs.dirname(picker:cwd())
vim.api.nvim_set_current_dir(parent) -- picker:set_cwd + picker:find
require('snacks.explorer.tree'):close_all(parent)
else
picker:action 'confirm'
end
end,
list_next = function(picker, item)
if item.dir then
local is_root = vim.iter(picker:selected { fallback = true }):any(function(v)
return not v.parent
end)
local up_stack = (picker.state or {}).up_stack
if is_root and up_stack and #up_stack > 0 then
vim.api.nvim_set_current_dir(table.remove(up_stack, #up_stack))
else
vim.api.nvim_set_current_dir(picker:dir())
end
else
picker:action 'confirm'
end
end,
},
win = {
list = {
keys = {
['<CR>'] = 'list_next',
['<BS>'] = 'list_prev',
},
},
},
},
},
},
},
},
},
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How can I configure the explorer so that directories are not grouped together but treated like regular files? Also, if there are any other special grouping rules, how can I disable them?
Beta Was this translation helpful? Give feedback.
All reactions