vim.pack.add({ "https://github.com/folke/which-key.nvim", }) local wk = require("which-key") wk.setup({ preset = "helix", }) wk.add({ { "", group = "tabs" }, { "c", group = "code" }, { "d", group = "debug" }, { "D", group = "Diffview", icon = { icon = "", color = "orange" } }, { "p", group = "Yanky", icon = { icon = "󰃮 ", color = "yellow" } }, { "dp", group = "profiler" }, { "f", group = "file/find" }, { "g", group = "git" }, { "gh", group = "hunks" }, { "q", group = "quit/session" }, { "s", group = "search" }, { "u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" } }, { "x", group = "diagnostics/quickfix", icon = { icon = "󱖫 ", color = "green" } }, { "[", group = "prev" }, { "]", group = "next" }, { "g", group = "goto" }, { "gs", group = "surround" }, { "z", group = "fold" }, { "b", group = "buffer", expand = function() return require("which-key.extras").expand.buf() end, }, { "w", group = "windows", proxy = "", expand = function() return require("which-key.extras").expand.win() end, }, -- better descriptions { "gx", desc = "Open with system app" }, { "fC", group = "Copy Path", { "fCf", function() vim.fn.setreg("+", vim.fn.expand("%:p")) -- Copy full file path to clipboard vim.notify("Copied full file path: " .. vim.fn.expand("%:p")) end, desc = "Copy full file path", }, { "fCn", function() vim.fn.setreg("+", vim.fn.expand("%:t")) -- Copy file name to clipboard vim.notify("Copied file name: " .. vim.fn.expand("%:t")) end, desc = "Copy file name", }, { "fCr", function() local cwd = vim.fn.getcwd() -- Current working directory local full_path = vim.fn.expand("%:p") -- Full file path local rel_path = full_path:sub(#cwd + 2) -- Remove cwd prefix and leading slash vim.fn.setreg("+", rel_path) -- Copy relative file path to clipboard vim.notify("Copied relative file path: " .. rel_path) end, desc = "Copy relative file path", }, { "?", function() require("which-key").show({ global = false }) end, desc = "Buffer Keymaps (which-key)", }, { "", function() require("which-key").show({ keys = "", loop = true }) end, desc = "Window Hydra Mode (which-key)", }, }, { -- Nested mappings are allowed and can be added in any order -- Most attributes can be inherited or overridden on any level -- There's no limit to the depth of nesting mode = { "n", "v" }, -- NORMAL and VISUAL mode { "q", "q", desc = "Quit" }, -- no need to specify mode since it's inherited { "w", "w", desc = "Write" }, }, })