Skip to content

Commit

Permalink
which-key and harpoon up to date configs
Browse files Browse the repository at this point in the history
  • Loading branch information
lipeeeee committed Jul 19, 2024
1 parent e2a27b4 commit 0248a8a
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 95 deletions.
6 changes: 3 additions & 3 deletions lua/lipe/plugins/git/gitsigns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ return {
row = 0,
col = 1
},
yadm = {
enable = false
},
-- yadm = {
-- enable = false
-- },
}
end
}
180 changes: 177 additions & 3 deletions lua/lipe/plugins/ui/which-key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,181 @@ return {
config = function()
-- Initialize which-key
local wk = require("which-key")
local opts = {

---@class wk.Opts
local new_opts = {
---@type false | "classic" | "modern" | "helix"
preset = "classic",
-- Delay before showing the popup. Can be a number or a function that returns a number.
---@type number | fun(ctx: { keys: string, mode: string, plugin?: string }):number
delay = function(ctx)
return ctx.plugin and 0 or 200
end,
---@param mapping wk.Mapping
filter = function(mapping)
-- example to exclude mappings without a description
-- return mapping.desc and mapping.desc ~= ""
return true
end,
--- You can add any mappings here, or use `require('which-key').add()` later
---@type wk.Spec
spec = {},
-- show a warning when issues were detected with your mappings
notify = true,
-- Which-key automatically sets up triggers for your mappings.
-- But you can disable this and setup the triggers manually.
-- Check the docs for more info.
---@type wk.Spec
triggers = {
{ "<auto>", mode = "nixsotc" },
},
-- Start hidden and wait for a key to be pressed before showing the popup
-- Only used by enabled xo mapping modes.
---@param ctx { mode: string, operator: string }
defer = function(ctx)
return ctx.mode == "V" or ctx.mode == "<C-V>"
end,
plugins = {
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
spelling = {
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
suggestions = 20, -- how many suggestions should be shown in the list?
},
presets = {
operators = true, -- adds help for operators like d, y, ...
motions = true, -- adds help for motions
text_objects = true, -- help for text objects triggered after entering an operator
windows = true, -- default bindings on <c-w>
nav = true, -- misc bindings to work with windows
z = true, -- bindings for folds, spelling and others prefixed with z
g = true, -- bindings for prefixed with g
},
},
---@type wk.Win.opts
win = {
-- don't allow the popup to overlap with the cursor
no_overlap = true,
-- width = 1,
-- height = { min = 4, max = 25 },
-- col = 0,
-- row = math.huge,
-- border = "none",
padding = { 1, 2 }, -- extra window padding [top/bottom, right/left]
title = true,
title_pos = "center",
zindex = 1000,
-- Additional vim.wo and vim.bo options
bo = {},
wo = {
-- winblend = 10, -- value between 0-100 0 for fully opaque and 100 for fully transparent
},
},
layout = {
width = { min = 20 }, -- min and max width of the columns
spacing = 3, -- spacing between columns
},
keys = {
scroll_down = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>", -- binding to scroll up inside the popup
},
---@type (string|wk.Sorter)[]
--- Mappings are sorted using configured sorters and natural sort of the keys
--- Available sorters:
--- * local: buffer-local mappings first
--- * order: order of the items (Used by plugins like marks / registers)
--- * group: groups last
--- * alphanum: alpha-numerical first
--- * mod: special modifier keys last
--- * manual: the order the mappings were added
--- * case: lower-case first
sort = { "local", "order", "group", "alphanum", "mod" },
---@type number|fun(node: wk.Node):boolean?
expand = 0, -- expand groups when <= n mappings
-- expand = function(node)
-- return not node.desc -- expand all nodes without a description
-- end,
-- Functions/Lua Patterns for formatting the labels
---@type table<string, ({[1]:string, [2]:string}|fun(str:string):string)[]>
replace = {
key = {
function(key)
return require("which-key.view").format(key)
end,
-- { "<Space>", "SPC" },
},
desc = {
{ "<Plug>%(?(.*)%)?", "%1" },
{ "^%+", "" },
{ "<[cC]md>", "" },
{ "<[cC][rR]>", "" },
{ "<[sS]ilent>", "" },
{ "^lua%s+", "" },
{ "^call%s+", "" },
{ "^:%s*", "" },
},
},
icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
separator = "", -- symbol used between a key and it's label
group = "+", -- symbol prepended to a group
ellipsis = "",
-- set to false to disable all mapping icons,
-- both those explicitely added in a mapping
-- and those from rules
mappings = true,
--- See `lua/which-key/icons.lua` for more details
--- Set to `false` to disable keymap icons from rules
---@type wk.IconRule[]|false
rules = {},
-- use the highlights from mini.icons
-- When `false`, it will use `WhichKeyIcon` instead
colors = true,
-- used by key format
keys = {
Up = "",
Down = "",
Left = "",
Right = "",
C = "󰘴 ",
M = "󰘵 ",
D = "󰘳 ",
S = "󰘶 ",
CR = "󰌑 ",
Esc = "󱊷 ",
ScrollWheelDown = "󱕐 ",
ScrollWheelUp = "󱕑 ",
NL = "󰌑 ",
BS = "󰁮",
Space = "󱁐 ",
Tab = "󰌒 ",
F1 = "󱊫",
F2 = "󱊬",
F3 = "󱊭",
F4 = "󱊮",
F5 = "󱊯",
F6 = "󱊰",
F7 = "󱊱",
F8 = "󱊲",
F9 = "󱊳",
F10 = "󱊴",
F11 = "󱊵",
F12 = "󱊶",
},
},
show_help = true, -- show a help message in the command line for using WhichKey
show_keys = true, -- show the currently pressed key and its label as a message in the command line
-- disable WhichKey for certain buf types and file types.
disable = {
ft = {},
bt = {},
},
debug = false, -- enable wk.log in the current directory
}

local old_opts = {
plugins = {
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
Expand Down Expand Up @@ -97,9 +271,9 @@ return {
filetypes = {},
},
}
wk.setup(opts)
wk.setup(new_opts)

-- Register keybinds
wk.register(require("lipe.preferences.keybinds"))
wk.add(require("lipe.preferences.keybinds"))
end
}
164 changes: 76 additions & 88 deletions lua/lipe/preferences/keybinds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,99 +7,87 @@ end

-- abcdefghijklmnopqrstuvxyz
return {
["<leader>"] = {

-- Buffer actions
b = {
name = "+Buffer",
["d"] = { _cmd("bd"), "Delete current buffer" },
["D"] = { _cmd("%bd|e#"), "Delete every other buffer" },
["l"] = { _cmd("Telescope buffers"), "List Buffers" },
},

-- Dynamic file explorer, input gotten from entry init.lua
["e"] = { _cmd(FILE_EXPLORERS[FILE_EXPLORER_TO_USE]), FILE_EXPLORER_TO_USE .. " Toggle" },

-- Git
g = {
name = "+Git",
a = { _cmd("Git add ."), "Add" },
b = { _cmd("Gitsigns blame_line"), "Blame" },
c = { _cmd("Git commit"), "Commit" },
l = { _cmd("Git log"), "Log" },
g = { _cmd("LazyGit"), "LazyGit" },
s = { _cmd("Git"), "Status" },
},

-- Harpoon
["h"] = {
name = "+Harpoon",
["a"] = { function() harpoon:list():append() end, "Add file" },
["e"] = { function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, "Menu" },
},

-- Help
["H"] = {
name = "+Help",
["k"] = { _cmd("Telescope keymaps"), "Keymaps" },
["t"] = { _cmd("Telescope builtin"), "Telescope" },
["T"] = { _cmd("Telescope help_tags"), "Tags" },
},

-- LSP
["l"] = {
name = "+LSP",
["f"] = { _cmd("lua vim.lsp.buf.format{ async = true }"), "Format" },
["r"] = { _cmd("lua vim.lsp.buf.rename()"), "Rename" },
["i"] = { _cmd("LspInfo"), "Info" },
["a"] = { _cmd("lua vim.lsp.buf.code_action()"), "Code Actions" },
["n"] = { _cmd("lua vim.diagnostic.goto_next({buffer=, opts0})"), "Diagnostics Next" },
["p"] = { _cmd("lua vim.diagnostic.goto_prev({buffer=, opts0})"), "Diagnostics Prev" },
["s"] = { _cmd("lua vim.lsp.buf.signature_help()"), "Signature Help" },
["t"] = { _cmd("TroubleToggle"), "Trouble" },
["q"] = { _cmd("lua vim.diagnostic.setloclist()"), "Loc List" },
},

-- Lazy
["L"] = { _cmd("Lazy"), "Lazy" },

-- Mason
["M"] = { _cmd("Mason"), "Mason" },

-- Telescope
["t"] = {
name = "+Telescope",
f = { _cmd("Telescope find_files"), "Find File" },
r = { _cmd("Telescope oldfiles"), "Recent Files" },
B = { _cmd("Telescope file_browser"), "File Browser" },
b = { _cmd("Telescope buffers"), "Buffers" },
c = { _cmd("Telescope neoclip"), "Clipboard" },
g = { _cmd("Telescope live_grep"), "Grep" }
},

-- Trouble
["T"] = { _cmd("Trouble"), "Trouble" },

["U"] = { _cmd("UndotreeToggle"), "Undotree" },

["z"] = { _cmd("ZenMode"), "Zen Mode" },
},
-- Dynamic file explorer, input gotten from entry init.lua
{ "<leader>e", _cmd(FILE_EXPLORERS[FILE_EXPLORER_TO_USE]), desc = FILE_EXPLORER_TO_USE .. " Toggle" },

-- Buffer actions
{ "<leader>b", group = "+Buffer" },
{ "<leader>bd", _cmd("bd"), desc = "Delete current buffer" },
{ "<leader>bD", _cmd("%bd|e#"), desc = "Delete every other buffer" },
{ "<leader>bl", _cmd("Telescope buffers"), desc = "List Buffers" },

-- Git
{ "<leader>g", group = "+Git" },
{ "<leader>ga", _cmd("Git add ."), desc = "Add" },
{ "<leader>gb", _cmd("Gitsigns blame_line"), desc = "Blame" },
{ "<leader>gc", _cmd("Git commit"), desc = "Commit" },
{ "<leader>gl", _cmd("Git log"), desc = "Log" },
{ "<leader>gg", _cmd("LazyGit"), desc = "LazyGit" },
{ "<leader>gs", _cmd("Git"), desc = "Status" },

-- Harpoon
{ "<leader>h", group = "+Harpoon" },
{ "<leader>ha", function() harpoon:list():add() end, desc = "Add file" },
{ "<leader>he", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, desc = "Menu" },

-- Help
{ "<leader>H", group = "+Help" },
{ "<leader>Hk", _cmd("Telescope keymaps"), desc = "Keymaps" },
{ "<leader>Ht", _cmd("Telescope builtin"), desc = "Telescope" },
{ "<leader>HT", _cmd("Telescope help_tags"), desc = "Tags" },

-- LSP
{ "<leader>l", group = "+LSP" },
{ "<leader>lf", _cmd("lua vim.lsp.buf.format{ async = true }"), desc = "Format" },
{ "<leader>lr", _cmd("lua vim.lsp.buf.rename()"), desc = "Rename" },
{ "<leader>li", _cmd("LspInfo"), desc = "Info" },
{ "<leader>la", _cmd("lua vim.lsp.buf.code_action()"), desc = "Code Actions" },
{ "<leader>ln", _cmd("lua vim.diagnostic.goto_next({buffer=, opts0})"), desc = "Diagnostics Next" },
{ "<leader>lp", _cmd("lua vim.diagnostic.goto_prev({buffer=, opts0})"), desc = "Diagnostics Prev" },
{ "<leader>ls", _cmd("lua vim.lsp.buf.signature_help()"), desc = "Signature Help" },
{ "<leader>lt", _cmd("TroubleToggle"), desc = "Trouble" },
{ "<leader>lq", _cmd("lua vim.diagnostic.setloclist()"), desc = "Loc List" },

-- Lazy
{ "<leader>L", _cmd("Lazy"), desc = "Lazy" },

-- Mason
{ "<leader>M", _cmd("Mason"), desc = "Mason" },

-- Telescope
{ "<leader>t", group = "+Telescope" },
{ "<leader>tf", _cmd("Telescope find_files"), desc = "Find File" },
{ "<leader>tr", _cmd("Telescope oldfiles"), desc = "Recent Files" },
{ "<leader>tB", _cmd("Telescope file_browser"), desc = "File Browser" },
{ "<leader>tb", _cmd("Telescope buffers"), desc = "Buffers" },
{ "<leader>tc", _cmd("Telescope neoclip"), desc = "Clipboard" },
{ "<leader>tg", _cmd("Telescope live_grep"), desc = "Grep" },

-- Trouble
{ "<leader>T", _cmd("Trouble"), desc = "Trouble" },

-- Undotree
{ "<leader>U", _cmd("UndotreeToggle"), desc = "Undotree" },

-- Zen mode
{ "<leader>z", _cmd("ZenMode"), desc = "Zen Mode" },

-- Non-Leader lsp bindings
["<C-space>"] = { _cmd("lua vim.lsp.buf.hover()"), "Lsp Hover Info" },
["gd"] = { _cmd("lua vim.lsp.buf.definition()"), "Go Definition" },
["gD"] = { _cmd("lua vim.lsp.buf.declaration()"), "Go Declaration" },
["gI"] = { _cmd("lua vim.lsp.buf.implementation()"), "Go Implementation" },
["gr"] = { _cmd("lua vim.lsp.buf.references()"), "Go References" },
{ "<C-space>", _cmd("lua vim.lsp.buf.hover()"), desc = "Lsp Hover Info" },
{ "gd", _cmd("lua vim.lsp.buf.definition()"), desc = "Go Definition" },
{ "gD", _cmd("lua vim.lsp.buf.declaration()"), desc = "Go Declaration" },
{ "gI", _cmd("lua vim.lsp.buf.implementation()"), desc = "Go Implementation" },
{ "gr", _cmd("lua vim.lsp.buf.references()"), desc = "Go References" },
-- ["gl"] = { _cmd("lua vim.diagnostic.open_float()"), "Go Diagnostics" },

-- Harpoon
["<A-1>"] = { function() harpoon:list():select(1) end, "Harpoon file 1" },
["<A-2>"] = { function() harpoon:list():select(2) end, "Harpoon file 2" },
["<A-3>"] = { function() harpoon:list():select(3) end, "Harpoon file 3" },
["<A-4>"] = { function() harpoon:list():select(4) end, "Harpoon file 4" },
["<A-5>"] = { function() harpoon:list():select(5) end, "Harpoon file 5" },
{ "<A-1>", function() harpoon:list():select(1) end, desc = "Harpoon file 1" },
{ "<A-2>", function() harpoon:list():select(2) end, desc = "Harpoon file 2" },
{ "<A-3>", function() harpoon:list():select(3) end, desc = "Harpoon file 3" },
{ "<A-4>", function() harpoon:list():select(4) end, desc = "Harpoon file 4" },
{ "<A-5>", function() harpoon:list():select(5) end, desc = "Harpoon file 5" },
{ "<A-6>", function() harpoon:list():select(6) end, desc = "Harpoon file 6" },

-- ToggleTerm
["<C-\\>"] = { _cmd("ToggleTerm"), "Terminal" },
{ "<C-\\>", _cmd("ToggleTerm"), desc = "Toggle Term" },
}
Loading

0 comments on commit 0248a8a

Please sign in to comment.