Replies: 1 comment
-
vim.keymap.set('n', '\\', function()
Snacks.picker.pick('explorer', {
dirs = { 'path1', 'path2' },
--
follow_file = false,
finder = function(opts, ctx)
local Tree = require 'snacks.explorer.tree'
local M = require 'snacks.picker.source.explorer'
local dirs = ctx.picker.opts.dirs
local state = M.get_state(ctx.picker)
-- if state:setup(ctx) then
-- return M.search(opts, ctx)
-- end
if not ctx.picker.shown then
vim.iter(dirs):each(function(dir)
Tree:close_all(dir)
end)
end
if opts.git_status then
vim.iter(dirs):each(function(dir)
require('snacks.explorer.git').update(dir, {
untracked = opts.git_untracked,
on_update = function()
if ctx.picker.closed then
return
end
ctx.picker.list:set_target()
ctx.picker:find()
end,
})
end)
end
if opts.diagnostics then
vim.iter(dirs):each(function(dir)
require('snacks.explorer.diagnostics').update(dir)
end)
end
return function(cb)
vim.iter(dirs):each(function(dir)
if state.on_find then
ctx.picker.matcher.task:on('done', vim.schedule_wrap(state.on_find))
state.on_find = nil
end
local items = {} ---@type table<string, snacks.picker.explorer.Item>
local top = Tree:find(dir)
local last = {} ---@type table<snacks.picker.explorer.Node, snacks.picker.explorer.Item>
Tree:get(dir, function(node)
local parent = node.parent and items[node.parent.path] or nil
local status = node.status
if not status and parent and parent.dir_status then
status = parent.dir_status
end
local item = {
file = node.path,
dir = node.dir,
open = node.open,
dir_status = node.dir_status or parent and parent.dir_status,
text = node.path,
parent = parent,
hidden = node.hidden,
ignored = node.ignored,
status = (not node.dir or not node.open or opts.git_status_open) and status or nil,
last = true,
type = node.type,
severity = (not node.dir or not node.open or opts.diagnostics_open) and node.severity or nil,
}
if last[node.parent] then
last[node.parent].last = false
end
last[node.parent] = item
if top == node then
item.hidden = false
item.ignored = false
end
items[node.path] = item
cb(item)
end, { hidden = opts.hidden, ignored = opts.ignored, exclude = opts.exclude, include = opts.include })
end)
end
end,
})
end) |
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.
-
Is it possible to define a custom list of favorite directories to allow quick navigation?
Beta Was this translation helpful? Give feedback.
All reactions