Files
NeoVim-Config/lua/config/keymaps.lua
T
2026-06-01 20:16:12 +03:00

22 lines
915 B
Lua

-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
-- Focus the Snacks Explorer if open, otherwise toggle/open it
vim.keymap.set({ "n", "t", "i" }, "<space>e", function()
-- Look for an already active explorer instance
local explorer = Snacks.picker.get({ source = "explorer" })[1]
if not explorer then
-- 1. If it's closed, open it fresh
Snacks.explorer()
elseif explorer:is_focused() then
-- 2. If we are inside the explorer, jump focus back to the code/file buffer
-- This relies on native window jumping to the last accessed window (the file)
vim.cmd("wincmd p")
else
-- 3. If explorer is open but we are in a file, just re-focus the explorer
explorer:focus()
end
end, { desc = "Smart Explorer Focus Toggle" })