-- Lua
return {
  "folke/which-key.nvim",
  event = "VeryLazy",
  init = function()
    vim.o.timeout = true
    vim.o.timeoutlen = 300

	local wk = require("which-key")

	-- local telescope = require('telescope.builtin')
	wk.add({
	  -- NvimTree
    { "<leader>e", group = "NvimTree" },
    { "<leader>ef", "<cmd>NvimTreeFindFileToggle<cr>", desc = "Toggle File Explorer on current file" },
    { "<leader>et", "<cmd>NvimTreeFindFileToggle<cr>", desc = "Toggle File Explorer" },

	  -- Telescope
    -- { "<leader>f", group = "fuzzy finder" },
    -- { "<leader>fb", telescope.buffers, desc = "Buffers" },
    -- { "<leader>ff", telescope.find_files, desc = "Find Files" },
    -- { "<C-p>", telescope.find_files, desc = "Find Files" },
    -- { "<leader>fg", telescope.live_grep, desc = "Grep Text" },
    -- { "<leader>fh", telescope.help_tags, desc = "Help tags" },

    -- ToggleTerm
    { "<leader>tt", "<cmd>ToggleTerm<cr>", desc = "Open Toggle Term" },

    -- claude code
    { "<leader>c", group = "AI/Claude Code" },

    -- Yazi
    { "<leader>y", group = "Yazi" },
    {
      "<leader>yf",
      mode = { "n", "v" },
      "<cmd>Yazi<cr>",
      desc = "Open yazi at the current file",
    },
    {
      -- Open in the current working directory
      "<leader>yc",
      "<cmd>Yazi cwd<cr>",
      desc = "Open the file manager in nvim's working directory",
    },
    {
      "<leader>yt",
      "<cmd>Yazi toggle<cr>",
      desc = "Resume the last yazi session",
    },

    -- esc to close terminal
    { "<esc><esc>", "<c-\\><c-n>", desc = "Terminal to normal mode", mode='t' },

    -- Barbar
    { "<leader>b", group = "Barbar" },
    { "<leader>bn", "<cmd>BufferNext<cr>", desc = "Next Buffer" },
    { "<leader>bp", "<cmd>BufferPrevious<cr>", desc = "Previous Buffer" },
    { "<leader>bd", "<cmd>BufferClose<cr>", desc = "Close Buffer" },
    { "bn", "<cmd>BufferNext<cr>", desc = "Next Buffer" },
    { "bp", "<cmd>BufferPrevious<cr>", desc = "Previous Buffer" },
    { "bN", "<cmd>BufferMoveNext<cr>", desc = "Move to Next Buffer" },
    { "bP", "<cmd>BufferMovePrevious<cr>", desc = "Move to Previous Buffer" },
    { "bd", "<cmd>BufferClose<cr>", desc = "Close Buffer" },
    { "gt", "<cmd>BufferNext<cr>", desc = "Next Buffer" },
    { "gT", "<cmd>BufferPrevious<cr>", desc = "Previous Buffer" },
    { "<leader>b1", "<cmd>BufferGoto 1<cr>", desc = "Goto Buffer 1" },
    { "<leader>b2", "<cmd>BufferGoto 2<cr>", desc = "Goto Buffer 2" },
    { "<leader>b3", "<cmd>BufferGoto 3<cr>", desc = "Goto Buffer 3" },
    { "<leader>b4", "<cmd>BufferGoto 4<cr>", desc = "Goto Buffer 4" },
    { "<leader>b5", "<cmd>BufferGoto 5<cr>", desc = "Goto Buffer 5" },
    { "<leader>b6", "<cmd>BufferGoto 6<cr>", desc = "Goto Buffer 6" },
    { "<leader>b7", "<cmd>BufferGoto 7<cr>", desc = "Goto Buffer 7" },
    { "<leader>b8", "<cmd>BufferGoto 8<cr>", desc = "Goto Buffer 8" },
    { "<leader>b9", "<cmd>BufferGoto 9<cr>", desc = "Goto Buffer 9" },
    { "<M-1>", "<cmd>BufferGoto 1<cr>", desc = "Goto Buffer 1" },
    { "<M-2>", "<cmd>BufferGoto 2<cr>", desc = "Goto Buffer 2" },
    { "<M-3>", "<cmd>BufferGoto 3<cr>", desc = "Goto Buffer 3" },
    { "<M-4>", "<cmd>BufferGoto 4<cr>", desc = "Goto Buffer 4" },
    { "<M-5>", "<cmd>BufferGoto 5<cr>", desc = "Goto Buffer 5" },
    { "<M-6>", "<cmd>BufferGoto 6<cr>", desc = "Goto Buffer 6" },
    { "<M-7>", "<cmd>BufferGoto 7<cr>", desc = "Goto Buffer 7" },
    { "<M-8>", "<cmd>BufferGoto 8<cr>", desc = "Goto Buffer 8" },
    { "<M-9>", "<cmd>BufferGoto 9<cr>", desc = "Goto Buffer 9" },

	  -- Others
    { "<leader>nh", "<cmd>nohl<cr>", desc = "Clear search highlights" },
    { "<leader>nd", "<cmd>Noice hide<cr>", desc = "Dismiss notifications" },
    -- { "T", "<cmd>tabnew<cr>", desc = "New Tab" },
  })

  end,
  opts = {}
}

-- vim: ts=2 sts=2 sw=2 expandtab
