Skip to content
Discussion options

You must be logged in to vote
---@module 'snacks'

-- Test keymap
vim.keymap.set("n", "<F1>", function()
  Snacks.explorer()
end)

---@param picker snacks.Picker
---@param key string
local save_explorer_state = function(picker, key)
  local dirs = {}
  for _, item in ipairs(picker:items()) do
    if item.dir then
      table.insert(dirs, {
        file = item.file,
        open = item.open,
      })
    end
  end
  local state = {
    cwd = picker:cwd(),
    cursor = picker:current().idx,
    dirs = dirs,
  }
  local all_states = vim.g.EXPLORER_STATES or {}
  all_states[key] = state
  vim.g.EXPLORER_STATES = all_states
  vim.cmd.wshada()
  vim.notify("Explorer state saved", vim.log.levels.DEBUG)
end

local Tree = require

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pczern
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants