From bb3c2361b1a286b128d602222bc0b32f91cde837 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 18 Jan 2025 14:22:57 -0800 Subject: [PATCH] chore(keymap): put all keymaps in one place Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/init.lua | 1 - lua/core/mapping.lua | 80 -------------------------------------------- lua/keymap/init.lua | 74 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 81 deletions(-) delete mode 100644 lua/core/mapping.lua diff --git a/lua/core/init.lua b/lua/core/init.lua index ccd62de..452fc57 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -101,7 +101,6 @@ local load_core = function() shell_config() require("core.options") - require("core.mapping") require("core.event") require("core.pack") require("keymap") diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua deleted file mode 100644 index 6bc9adb..0000000 --- a/lua/core/mapping.lua +++ /dev/null @@ -1,80 +0,0 @@ -local bind = require("keymap.bind") -local map_cr = bind.map_cr -local map_cu = bind.map_cu -local map_cmd = bind.map_cmd - --- Core mappings -local core_map = { - -- Vim map - ["n|"] = map_cu("lua _flash_esc_or_noh()"):with_noremap():with_silent(), - ["n|"] = map_cr("normal za"):with_noremap():with_silent(), - ["n|"] = map_cu("write"):with_noremap():with_silent(), - ["n|Y"] = map_cmd("y$"), - ["n|D"] = map_cmd("d$"), - ["n|n"] = map_cmd("nzzzv"):with_noremap(), - ["n|N"] = map_cmd("Nzzzv"):with_noremap(), - ["n|J"] = map_cmd("mzJ`z"):with_noremap(), - ["n|"] = map_cmd("h"):with_noremap(), - ["n|"] = map_cmd("l"):with_noremap(), - ["n|"] = map_cmd("j"):with_noremap(), - ["n|"] = map_cmd("k"):with_noremap(), - ["t|"] = map_cmd("wincmd h"):with_silent():with_noremap(), - ["t|"] = map_cmd("wincmd k"):with_silent():with_noremap(), - ["n|“"] = map_cr("vertical resize -5"):with_silent(), - ["n|‘"] = map_cr("vertical resize +5"):with_silent(), - ["n|…"] = map_cr("resize -2"):with_silent(), - ["n|æ"] = map_cr("resize +2"):with_silent(), - ["n|"] = map_cr("wq"):with_noremap():with_silent(), - ["n|Œ"] = map_cr("q!"):with_noremap():with_silent(), - ["n|c"] = map_cr("setlocal spell! spelllang=en_us"):with_noremap(), - ["x|p"] = map_cmd('"_dP'):with_silent():with_noremap(), - ["n|+"] = map_cmd(""):with_noremap():with_silent(), - ["n|-"] = map_cmd(""):with_noremap():with_silent(), - ["n|"] = map_cmd("gg0vG$"):with_noremap():with_silent(), - ["x|"] = map_cmd("gg0vG$"):with_noremap():with_silent(), - ["n|qa"] = map_cr("cabove"):with_noremap():with_silent(), - ["n|qb"] = map_cr("cbelow"):with_noremap():with_silent(), - ["n|qf"] = map_cr("cfirst"):with_noremap():with_silent(), - ["n|ql"] = map_cr("clast"):with_noremap():with_silent(), - ["n|qn"] = map_cr("cnext"):with_noremap():with_silent(), - ["n|qp"] = map_cr("cprevious"):with_noremap():with_silent(), - ["n|qo"] = map_cr("copen"):with_noremap():with_silent(), - ["n|qc"] = map_cr("cclose"):with_noremap():with_silent(), - ["n|qq"] = map_cr("cclose"):with_noremap():with_silent(), - ["n|tc"] = map_cr("tabclose"):with_noremap():with_silent(), - ["n|td"] = map_cr("tabclose"):with_noremap():with_silent(), - ["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent(), - ["n|tp"] = map_cr("tabprevious"):with_noremap():with_silent(), - ["n|tk"] = map_cr("tabnext"):with_noremap():with_silent(), - ["n|tn"] = map_cr("tabnext"):with_noremap():with_silent(), - ["n|tN"] = map_cr("tabnew"):with_noremap():with_silent(), - ["n|to"] = map_cr("tabonly"):with_noremap():with_silent(), - -- Insert mode - ["i|"] = map_cmd("u"):with_noremap(), - ["i|"] = map_cmd(""):with_noremap(), - ["i|"] = map_cmd("^i"):with_noremap(), - ["i|"] = map_cmd(":w"), - ["i|"] = map_cmd(":wq"), - -- Command mode - ["c|"] = map_cmd(""):with_noremap(), - ["c|"] = map_cmd(""):with_noremap(), - ["c|"] = map_cmd(""):with_noremap(), - ["c|"] = map_cmd(""):with_noremap(), - ["c|"] = map_cmd(""):with_noremap(), - ["c|"] = map_cmd(""):with_noremap(), - ["c|"] = map_cmd(""):with_noremap(), - ["c|%%"] = map_cmd([[getcmdtype() == ':' ? expand('%:h').'/' : '%%']]):with_expr():with_noremap(), - -- Visual mode - ["v|J"] = map_cmd(":m '>+1gv=gv"):with_silent(), - ["v|K"] = map_cmd(":m '<-2gv=gv"):with_silent(), - ["v|<"] = map_cmd(""] = map_cmd(">gv"):with_silent(), - -- Accoustomed Settings - ["n|¨"] = map_cr("setlocal undofile! undofile?"):with_noremap(), - ["n|"] = map_cmd("ResizeWindowUp"):with_silent():with_noremap(), - ["n|"] = map_cmd("ResizeWindowDown"):with_silent():with_noremap(), - ["n|"] = map_cmd("ResizeWindowLeft"):with_silent():with_noremap(), - ["n|"] = map_cmd("ResizeWindowRight"):with_silent():with_noremap(), -} - -bind.nvim_load_mapping(core_map) diff --git a/lua/keymap/init.lua b/lua/keymap/init.lua index 9469fda..d5d0c80 100644 --- a/lua/keymap/init.lua +++ b/lua/keymap/init.lua @@ -4,6 +4,79 @@ local map_cu = bind.map_cu local map_cmd = bind.map_cmd require("keymap.config") +local core_map = { + -- Vim map + ["n|"] = map_cu("lua _flash_esc_or_noh()"):with_noremap():with_silent(), + ["n|"] = map_cr("normal za"):with_noremap():with_silent(), + ["n|"] = map_cu("write"):with_noremap():with_silent(), + ["n|Y"] = map_cmd("y$"), + ["n|D"] = map_cmd("d$"), + ["n|n"] = map_cmd("nzzzv"):with_noremap(), + ["n|N"] = map_cmd("Nzzzv"):with_noremap(), + ["n|J"] = map_cmd("mzJ`z"):with_noremap(), + ["n|"] = map_cmd("h"):with_noremap(), + ["n|"] = map_cmd("l"):with_noremap(), + ["n|"] = map_cmd("j"):with_noremap(), + ["n|"] = map_cmd("k"):with_noremap(), + ["t|"] = map_cmd("wincmd h"):with_silent():with_noremap(), + ["t|"] = map_cmd("wincmd k"):with_silent():with_noremap(), + ["n|“"] = map_cr("vertical resize -5"):with_silent(), + ["n|‘"] = map_cr("vertical resize +5"):with_silent(), + ["n|…"] = map_cr("resize -2"):with_silent(), + ["n|æ"] = map_cr("resize +2"):with_silent(), + ["n|"] = map_cr("wq"):with_noremap():with_silent(), + ["n|Œ"] = map_cr("q!"):with_noremap():with_silent(), + ["n|c"] = map_cr("setlocal spell! spelllang=en_us"):with_noremap(), + ["x|p"] = map_cmd('"_dP'):with_silent():with_noremap(), + ["n|+"] = map_cmd(""):with_noremap():with_silent(), + ["n|-"] = map_cmd(""):with_noremap():with_silent(), + ["n|"] = map_cmd("gg0vG$"):with_noremap():with_silent(), + ["x|"] = map_cmd("gg0vG$"):with_noremap():with_silent(), + ["n|qa"] = map_cr("cabove"):with_noremap():with_silent(), + ["n|qb"] = map_cr("cbelow"):with_noremap():with_silent(), + ["n|qf"] = map_cr("cfirst"):with_noremap():with_silent(), + ["n|ql"] = map_cr("clast"):with_noremap():with_silent(), + ["n|qn"] = map_cr("cnext"):with_noremap():with_silent(), + ["n|qp"] = map_cr("cprevious"):with_noremap():with_silent(), + ["n|qo"] = map_cr("copen"):with_noremap():with_silent(), + ["n|qc"] = map_cr("cclose"):with_noremap():with_silent(), + ["n|qq"] = map_cr("cclose"):with_noremap():with_silent(), + ["n|tc"] = map_cr("tabclose"):with_noremap():with_silent(), + ["n|td"] = map_cr("tabclose"):with_noremap():with_silent(), + ["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent(), + ["n|tp"] = map_cr("tabprevious"):with_noremap():with_silent(), + ["n|tk"] = map_cr("tabnext"):with_noremap():with_silent(), + ["n|tn"] = map_cr("tabnext"):with_noremap():with_silent(), + ["n|tN"] = map_cr("tabnew"):with_noremap():with_silent(), + ["n|to"] = map_cr("tabonly"):with_noremap():with_silent(), + -- Insert mode + ["i|"] = map_cmd("u"):with_noremap(), + ["i|"] = map_cmd(""):with_noremap(), + ["i|"] = map_cmd("^i"):with_noremap(), + ["i|"] = map_cmd(":w"), + ["i|"] = map_cmd(":wq"), + -- Command mode + ["c|"] = map_cmd(""):with_noremap(), + ["c|"] = map_cmd(""):with_noremap(), + ["c|"] = map_cmd(""):with_noremap(), + ["c|"] = map_cmd(""):with_noremap(), + ["c|"] = map_cmd(""):with_noremap(), + ["c|"] = map_cmd(""):with_noremap(), + ["c|"] = map_cmd(""):with_noremap(), + ["c|%%"] = map_cmd([[getcmdtype() == ':' ? expand('%:h').'/' : '%%']]):with_expr():with_noremap(), + -- Visual mode + ["v|J"] = map_cmd(":m '>+1gv=gv"):with_silent(), + ["v|K"] = map_cmd(":m '<-2gv=gv"):with_silent(), + ["v|<"] = map_cmd(""] = map_cmd(">gv"):with_silent(), + -- Accoustomed Settings + ["n|¨"] = map_cr("setlocal undofile! undofile?"):with_noremap(), + ["n|"] = map_cmd("ResizeWindowUp"):with_silent():with_noremap(), + ["n|"] = map_cmd("ResizeWindowDown"):with_silent():with_noremap(), + ["n|"] = map_cmd("ResizeWindowLeft"):with_silent():with_noremap(), + ["n|"] = map_cmd("ResizeWindowRight"):with_silent():with_noremap(), +} + local plug_map = { -- Bufferline ["n|∆"] = map_cr("BufferLineCyclePrev"):with_noremap():with_silent(), @@ -166,4 +239,5 @@ local plug_map = { ["n|gF"] = map_cr("DiffviewClose"):with_silent():with_noremap(), } +bind.nvim_load_mapping(core_map) bind.nvim_load_mapping(plug_map)