-- whichkey.lua -- Check if which-key is available local has_which_key, which_key = pcall(require, "which-key") if not has_which_key then print("Warning: which-key not found. Key binding help won't be available.") return end -- Set up which-key with error handling local setup_ok, _ = pcall(which_key.setup, { plugins = { marks = true, registers = true, spelling = { enabled = true, suggestions = 20, }, presets = { operators = true, motions = true, text_objects = true, windows = true, nav = true, z = true, g = true, }, }, window = { border = "rounded", padding = { 2, 2, 2, 2 }, }, layout = { height = { min = 4, max = 25 }, width = { min = 20, max = 50 }, }, ignore_missing = false, }) if not setup_ok then print("Error setting up which-key. Key binding help won't work correctly.") return end -- Register key bindings with which-key local register_ok, _ = pcall(which_key.register, { f = { name = "File", -- Optional group name f = { "Telescope find_files", "Find File" }, r = { "Telescope oldfiles", "Recent Files" }, g = { "Telescope live_grep", "Live Grep" }, b = { "Telescope buffers", "Buffers" }, n = { "enew", "New File" }, }, e = { "NvimTreeToggle", "Explorer" }, l = { name = "LSP", d = { "Telescope lsp_definitions", "Definitions" }, r = { "Telescope lsp_references", "References" }, a = { "lua vim.lsp.buf.code_action()", "Code Action" }, f = { "lua vim.lsp.buf.format()", "Format" }, h = { "lua vim.lsp.buf.hover()", "Hover" }, R = { "lua vim.lsp.buf.rename()", "Rename" }, }, b = { name = "Buffer", n = { "bnext", "Next Buffer" }, p = { "bprevious", "Previous Buffer" }, d = { "bdelete", "Delete Buffer" }, }, }, { prefix = "" }) if not register_ok then print("Error registering which-key bindings.") return end print("Key binding help initialized!")