Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register readable prefix for grouped keymap settings #1134

Merged
merged 19 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ local load_core = function()

require("core.options")
require("core.mapping")
require("keymap")
require("core.event")
require("core.pack")
require("keymap")

local colorscheme = settings.colorscheme
local background = settings.background
Expand Down
6 changes: 3 additions & 3 deletions lua/keymap/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function mapping.lsp(buf)
:with_silent()
:with_buffer(buf)
:with_desc("lsp: Next diagnostic"),
["n|<leader>ld"] = map_cr("Lspsaga show_line_diagnostics ++unfocus")
["n|<leader>lx"] = map_cr("Lspsaga show_line_diagnostics ++unfocus")
:with_silent()
:with_buffer(buf)
:with_desc("lsp: Line diagnostic"),
Expand All @@ -50,11 +50,11 @@ function mapping.lsp(buf)
["n|gd"] = map_cr("Glance definitions"):with_silent():with_buffer(buf):with_desc("lsp: Preview definition"),
["n|gD"] = map_cr("Lspsaga goto_definition"):with_silent():with_buffer(buf):with_desc("lsp: Goto definition"),
["n|gh"] = map_cr("Glance references"):with_silent():with_buffer(buf):with_desc("lsp: Show reference"),
["n|<leader>ci"] = map_cr("Lspsaga incoming_calls")
["n|gci"] = map_cr("Lspsaga incoming_calls")
:with_silent()
:with_buffer(buf)
:with_desc("lsp: Show incoming calls"),
["n|<leader>co"] = map_cr("Lspsaga outgoing_calls")
["n|gco"] = map_cr("Lspsaga outgoing_calls")
:with_silent()
:with_buffer(buf)
:with_desc("lsp: Show outgoing calls"),
Expand Down
6 changes: 3 additions & 3 deletions lua/keymap/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ local plug_map = {
:with_desc("edit: Toggle comment for block with selection"),

-- Plugin: diffview
["n|<leader>D"] = map_cr("DiffviewOpen"):with_silent():with_noremap():with_desc("git: Show diff"),
["n|<leader><leader>D"] = map_cr("DiffviewClose"):with_silent():with_noremap():with_desc("git: Close diff"),
["n|<leader>gd"] = map_cr("DiffviewOpen"):with_silent():with_noremap():with_desc("git: Show diff"),
["n|<leader>gD"] = map_cr("DiffviewClose"):with_silent():with_noremap():with_desc("git: Close diff"),

-- Plugin: vim-easy-align
["nx|gea"] = map_cr("EasyAlign"):with_desc("edit: Align with delimiter"),
Expand All @@ -68,7 +68,7 @@ local plug_map = {
["nv|<leader>j"] = map_cmd("<Cmd>HopLineMW<CR>"):with_noremap():with_desc("jump: Goto line"),
["nv|<leader>k"] = map_cmd("<Cmd>HopLineMW<CR>"):with_noremap():with_desc("jump: Goto line"),
["nv|<leader>c"] = map_cmd("<Cmd>HopChar1MW<CR>"):with_noremap():with_desc("jump: Goto one char"),
["nv|<leader>cc"] = map_cmd("<Cmd>HopChar2MW<CR>"):with_noremap():with_desc("jump: Goto two chars"),
["nv|<leader>C"] = map_cmd("<Cmd>HopChar2MW<CR>"):with_noremap():with_desc("jump: Goto two chars"),

-- Plugin: treehopper
["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"),
Expand Down
16 changes: 8 additions & 8 deletions lua/keymap/tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local plug_map = {
-- Plugin: vim-fugitive
["n|gps"] = map_cr("G push"):with_noremap():with_silent():with_desc("git: Push"),
["n|gpl"] = map_cr("G pull"):with_noremap():with_silent():with_desc("git: Pull"),
["n|<leader>G"] = map_cu("Git"):with_noremap():with_silent():with_desc("git: Open git-fugitive"),
["n|<leader>gG"] = map_cu("Git"):with_noremap():with_silent():with_desc("git: Open git-fugitive"),

-- Plugin: nvim-tree
["n|<C-n>"] = map_cr("NvimTreeToggle"):with_noremap():with_silent():with_desc("filetree: Toggle"),
Expand Down Expand Up @@ -55,7 +55,7 @@ local plug_map = {
:with_silent()
:with_desc("terminal: Toggle float"),
["t|<A-d>"] = map_cmd("<Cmd>ToggleTerm<CR>"):with_noremap():with_silent():with_desc("terminal: Toggle float"),
["n|<leader>g"] = map_callback(function()
["n|<leader>gg"] = map_callback(function()
_toggle_lazygit()
end)
:with_noremap()
Expand All @@ -64,23 +64,23 @@ local plug_map = {

-- Plugin: trouble
["n|gt"] = map_cr("TroubleToggle"):with_noremap():with_silent():with_desc("lsp: Toggle trouble list"),
["n|<leader>tr"] = map_cr("TroubleToggle lsp_references")
["n|<leader>ll"] = map_cr("TroubleToggle lsp_references")
:with_noremap()
:with_silent()
:with_desc("lsp: Show lsp references"),
["n|<leader>td"] = map_cr("TroubleToggle document_diagnostics")
["n|<leader>ld"] = map_cr("TroubleToggle document_diagnostics")
:with_noremap()
:with_silent()
:with_desc("lsp: Show document diagnostics"),
["n|<leader>tw"] = map_cr("TroubleToggle workspace_diagnostics")
["n|<leader>lw"] = map_cr("TroubleToggle workspace_diagnostics")
:with_noremap()
:with_silent()
:with_desc("lsp: Show workspace diagnostics"),
["n|<leader>tq"] = map_cr("TroubleToggle quickfix")
["n|<leader>lq"] = map_cr("TroubleToggle quickfix")
:with_noremap()
:with_silent()
:with_desc("lsp: Show quickfix list"),
["n|<leader>tl"] = map_cr("TroubleToggle loclist"):with_noremap():with_silent():with_desc("lsp: Show loclist"),
["n|<leader>lL"] = map_cr("TroubleToggle loclist"):with_noremap():with_silent():with_desc("lsp: Show loclist"),

-- Plugin: telescope
["n|<C-p>"] = map_callback(function()
Expand Down Expand Up @@ -121,7 +121,7 @@ local plug_map = {
:with_noremap()
:with_silent()
:with_desc("ui: Change colorscheme for current session"),
["n|<leader>fn"] = map_cu(":enew"):with_noremap():with_silent():with_desc("buffer: New"),
["n|<leader>bn"] = map_cu(":enew"):with_noremap():with_silent():with_desc("buffer: New"),
["n|<leader>fg"] = map_cu("Telescope git_files")
:with_noremap()
:with_silent()
Expand Down
16 changes: 8 additions & 8 deletions lua/keymap/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,42 +54,42 @@ function mapping.gitsigns(buf)
:with_buffer(buf)
:with_expr()
:with_desc("git: Goto prev hunk"),
["n|<leader>hs"] = bind.map_callback(function()
["n|<leader>gs"] = bind.map_callback(function()
actions.stage_hunk()
end)
:with_buffer(buf)
:with_desc("git: Stage hunk"),
["v|<leader>hs"] = bind.map_callback(function()
["v|<leader>gs"] = bind.map_callback(function()
actions.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
:with_buffer(buf)
:with_desc("git: Stage hunk"),
["n|<leader>hu"] = bind.map_callback(function()
["n|<leader>gu"] = bind.map_callback(function()
actions.undo_stage_hunk()
end)
:with_buffer(buf)
:with_desc("git: Undo stage hunk"),
["n|<leader>hr"] = bind.map_callback(function()
["n|<leader>gr"] = bind.map_callback(function()
actions.reset_hunk()
end)
:with_buffer(buf)
:with_desc("git: Reset hunk"),
["v|<leader>hr"] = bind.map_callback(function()
["v|<leader>gr"] = bind.map_callback(function()
actions.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
:with_buffer(buf)
:with_desc("git: Reset hunk"),
["n|<leader>hR"] = bind.map_callback(function()
["n|<leader>gR"] = bind.map_callback(function()
actions.reset_buffer()
end)
:with_buffer(buf)
:with_desc("git: Reset buffer"),
["n|<leader>hp"] = bind.map_callback(function()
["n|<leader>gp"] = bind.map_callback(function()
actions.preview_hunk()
end)
:with_buffer(buf)
:with_desc("git: Preview hunk"),
["n|<leader>hb"] = bind.map_callback(function()
["n|<leader>gb"] = bind.map_callback(function()
actions.blame_line({ full = true })
end)
:with_buffer(buf)
Expand Down
33 changes: 32 additions & 1 deletion lua/modules/configs/tool/which-key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,39 @@ return function()
local icons = {
ui = require("modules.utils.icons").get("ui"),
misc = require("modules.utils.icons").get("misc"),
git = require("modules.utils.icons").get("git", true),
cmp = require("modules.utils.icons").get("cmp", true),
}

require("which-key").register({
["<leader>"] = {
b = {
name = icons.ui.Buffer .. " Buffer",
},
d = {
name = icons.ui.Bug .. " Debug",
},
f = {
name = icons.ui.Telescope .. " Fuzzy Find",
},
g = {
name = icons.git.Git .. "Git",
},
l = {
name = icons.misc.LspAvailable .. " Lsp",
},
n = {
name = icons.ui.FolderOpen .. " Nvim Tree",
},
p = {
name = icons.ui.Package .. " Package",
},
s = {
name = icons.cmp.tmux .. "Session",
},
},
})

require("modules.utils").load_plugin("which-key", {
plugins = {
presets = {
Expand All @@ -20,7 +51,7 @@ return function()
icons = {
breadcrumb = icons.ui.Separator,
separator = icons.misc.Vbar,
group = icons.misc.Add,
group = "",
},

window = {
Expand Down
8 changes: 0 additions & 8 deletions lua/modules/configs/ui/alpha.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ return function()
require("telescope.builtin").find_files()
end,
}),
button("space f n", " File new", leader, nil, {
noremap = true,
silent = true,
nowait = true,
callback = function()
vim.api.nvim_command("enew")
end,
}),
button("space f w", " Word find", leader, nil, {
noremap = true,
silent = true,
Expand Down
4 changes: 3 additions & 1 deletion lua/modules/utils/icons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ local data = {
BigCircle = "",
BigUnfilledCircle = "",
BookMark = "󰃃",
Buffer = "󰓩",
Bug = "",
Calendar = "",
Character = "",
Check = "󰄳",
ChevronRight = "",
Circle = "",
Close = "󰅖",
Close_alt = "",
CloudDownload = "",
Comment = "󰅺",
CodeAction = "󰌵",
Comment = "󰅺",
Dashboard = "",
Emoji = "󰱫",
EmptyFolder = "",
Expand Down