Skip to content

Commit f475d96

Browse files
chores: rearrange wm keymaps (#1363)
1 parent 693f0a0 commit f475d96

File tree

7 files changed

+93
-92
lines changed

7 files changed

+93
-92
lines changed

lua/core/init.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ local load_core = function()
104104
shell_config()
105105

106106
require("core.options")
107-
require("core.mapping")
108107
require("core.event")
109108
require("core.pack")
110109
require("keymap")

lua/core/mapping.lua

Lines changed: 0 additions & 65 deletions
This file was deleted.

lua/keymap/editor.lua

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,60 @@ local map_cmd = bind.map_cmd
55
local map_callback = bind.map_callback
66
local et = bind.escape_termcode
77

8+
local builtin_map = {
9+
-- Builtin: save & quit
10+
["n|<C-s>"] = map_cu("write"):with_noremap():with_silent():with_desc("edit: Save file"),
11+
["n|<C-q>"] = map_cr("wq"):with_desc("edit: Save file and quit"),
12+
["n|<A-S-q>"] = map_cr("q!"):with_desc("edit: Force quit"),
13+
14+
-- Builtin: insert mode
15+
["i|<C-u>"] = map_cmd("<C-G>u<C-U>"):with_noremap():with_desc("edit: Delete previous block"),
16+
["i|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("edit: Move cursor to left"),
17+
["i|<C-a>"] = map_cmd("<ESC>^i"):with_noremap():with_desc("edit: Move cursor to line start"),
18+
["i|<C-s>"] = map_cmd("<Esc>:w<CR>"):with_desc("edit: Save file"),
19+
["i|<C-q>"] = map_cmd("<Esc>:wq<CR>"):with_desc("edit: Save file and quit"),
20+
21+
-- Builtin: command mode
22+
["c|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("edit: Left"),
23+
["c|<C-f>"] = map_cmd("<Right>"):with_noremap():with_desc("edit: Right"),
24+
["c|<C-a>"] = map_cmd("<Home>"):with_noremap():with_desc("edit: Home"),
25+
["c|<C-e>"] = map_cmd("<End>"):with_noremap():with_desc("edit: End"),
26+
["c|<C-d>"] = map_cmd("<Del>"):with_noremap():with_desc("edit: Delete"),
27+
["c|<C-h>"] = map_cmd("<BS>"):with_noremap():with_desc("edit: Backspace"),
28+
["c|<C-t>"] = map_cmd([[<C-R>=expand("%:p:h") . "/" <CR>]])
29+
:with_noremap()
30+
:with_desc("edit: Complete path of current file"),
31+
32+
-- Builtin: visual mode
33+
["v|J"] = map_cmd(":m '>+1<CR>gv=gv"):with_desc("edit: Move this line down"),
34+
["v|K"] = map_cmd(":m '<-2<CR>gv=gv"):with_desc("edit: Move this line up"),
35+
["v|<"] = map_cmd("<gv"):with_desc("edit: Decrease indent"),
36+
["v|>"] = map_cmd(">gv"):with_desc("edit: Increase indent"),
37+
38+
-- Builtin: suckless
39+
["n|Y"] = map_cmd("y$"):with_desc("edit: Yank text to EOL"),
40+
["n|D"] = map_cmd("d$"):with_desc("edit: Delete text to EOL"),
41+
["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("edit: Next search result"),
42+
["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("edit: Prev search result"),
43+
["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("edit: Join next line"),
44+
["n|<S-Tab>"] = map_cr("normal za"):with_noremap():with_silent():with_desc("edit: Toggle code fold"),
45+
["n|<Esc>"] = map_callback(function()
46+
_flash_esc_or_noh()
47+
end)
48+
:with_noremap()
49+
:with_silent()
50+
:with_desc("edit: Clear search highlight"),
51+
["n|<leader>o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"),
52+
}
53+
54+
bind.nvim_load_mapping(builtin_map)
55+
856
local plug_map = {
9-
-- Plugin persisted.nvim
57+
-- Plugin: persisted.nvim
1058
["n|<leader>ss"] = map_cu("SessionSave"):with_noremap():with_silent():with_desc("session: Save"),
1159
["n|<leader>sl"] = map_cu("SessionLoad"):with_noremap():with_silent():with_desc("session: Load current"),
1260
["n|<leader>sd"] = map_cu("SessionDelete"):with_noremap():with_silent():with_desc("session: Delete"),
1361

14-
-- Plugin: nvim-bufdel
15-
["n|<A-q>"] = map_cr("BufDel"):with_noremap():with_silent():with_desc("buffer: Close current"),
16-
1762
-- Plugin: comment.nvim
1863
["n|gcc"] = map_callback(function()
1964
return vim.v.count == 0 and et("<Plug>(comment_toggle_linewise_current)")
@@ -59,20 +104,6 @@ local plug_map = {
59104
["nv|<leader>c"] = map_cmd("<Cmd>HopChar1MW<CR>"):with_noremap():with_desc("jump: Goto one char"),
60105
["nv|<leader>C"] = map_cmd("<Cmd>HopChar2MW<CR>"):with_noremap():with_desc("jump: Goto two chars"),
61106

62-
-- Plugin: smart-splits.nvim
63-
["n|<A-h>"] = map_cu("SmartResizeLeft"):with_silent():with_noremap():with_desc("window: Resize -3 horizontally"),
64-
["n|<A-j>"] = map_cu("SmartResizeDown"):with_silent():with_noremap():with_desc("window: Resize -3 vertically"),
65-
["n|<A-k>"] = map_cu("SmartResizeUp"):with_silent():with_noremap():with_desc("window: Resize +3 vertically"),
66-
["n|<A-l>"] = map_cu("SmartResizeRight"):with_silent():with_noremap():with_desc("window: Resize +3 horizontally"),
67-
["n|<C-h>"] = map_cu("SmartCursorMoveLeft"):with_silent():with_noremap():with_desc("window: Focus left"),
68-
["n|<C-j>"] = map_cu("SmartCursorMoveDown"):with_silent():with_noremap():with_desc("window: Focus down"),
69-
["n|<C-k>"] = map_cu("SmartCursorMoveUp"):with_silent():with_noremap():with_desc("window: Focus up"),
70-
["n|<C-l>"] = map_cu("SmartCursorMoveRight"):with_silent():with_noremap():with_desc("window: Focus right"),
71-
["n|<leader>Wh"] = map_cu("SmartSwapLeft"):with_silent():with_noremap():with_desc("window: Move window leftward"),
72-
["n|<leader>Wj"] = map_cu("SmartSwapDown"):with_silent():with_noremap():with_desc("window: Move window downward"),
73-
["n|<leader>Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window upward"),
74-
["n|<leader>Wl"] = map_cu("SmartSwapRight"):with_silent():with_noremap():with_desc("window: Move window rightward"),
75-
76107
-- Plugin: nvim-spectre
77108
["n|<leader>Ss"] = map_callback(function()
78109
require("spectre").toggle()
@@ -102,7 +133,7 @@ local plug_map = {
102133
-- Plugin: nvim-treehopper
103134
["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"),
104135

105-
-- Plugin suda.vim
136+
-- Plugin: suda.vim
106137
["n|<A-s>"] = map_cu("SudaWrite"):with_silent():with_noremap():with_desc("editn: Save file using sudo"),
107138
}
108139

lua/keymap/ui.lua

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
local bind = require("keymap.bind")
22
local map_cr = bind.map_cr
3-
-- local map_cu = bind.map_cu
4-
-- local map_cmd = bind.map_cmd
3+
local map_cu = bind.map_cu
4+
local map_cmd = bind.map_cmd
55
-- local map_callback = bind.map_callback
66

7+
local builtin_map = {
8+
-- Builtin: buffer
9+
["n|<leader>bn"] = map_cu("enew"):with_noremap():with_silent():with_desc("buffer: New"),
10+
11+
-- Builtin: terminal
12+
["t|<C-w>h"] = map_cmd("<Cmd>wincmd h<CR>"):with_silent():with_noremap():with_desc("window: Focus left"),
13+
["t|<C-w>l"] = map_cmd("<Cmd>wincmd l<CR>"):with_silent():with_noremap():with_desc("window: Focus right"),
14+
["t|<C-w>j"] = map_cmd("<Cmd>wincmd j<CR>"):with_silent():with_noremap():with_desc("window: Focus down"),
15+
["t|<C-w>k"] = map_cmd("<Cmd>wincmd k<CR>"):with_silent():with_noremap():with_desc("window: Focus up"),
16+
17+
-- Builtin: tab
18+
["n|tn"] = map_cr("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"),
19+
["n|tk"] = map_cr("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"),
20+
["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"),
21+
["n|to"] = map_cr("tabonly"):with_noremap():with_silent():with_desc("tab: Only keep current tab"),
22+
}
23+
24+
bind.nvim_load_mapping(builtin_map)
25+
726
local plug_map = {
27+
-- Plugin: nvim-bufdel
28+
["n|<A-q>"] = map_cr("BufDel"):with_noremap():with_silent():with_desc("buffer: Close current"),
29+
830
-- Plugin: bufferline.nvim
931
["n|<A-i>"] = map_cr("BufferLineCycleNext"):with_noremap():with_silent():with_desc("buffer: Switch to next"),
1032
["n|<A-o>"] = map_cr("BufferLineCyclePrev"):with_noremap():with_silent():with_desc("buffer: Switch to prev"),
@@ -21,6 +43,20 @@ local plug_map = {
2143
["n|<A-7>"] = map_cr("BufferLineGoToBuffer 7"):with_noremap():with_silent():with_desc("buffer: Goto buffer 7"),
2244
["n|<A-8>"] = map_cr("BufferLineGoToBuffer 8"):with_noremap():with_silent():with_desc("buffer: Goto buffer 8"),
2345
["n|<A-9>"] = map_cr("BufferLineGoToBuffer 9"):with_noremap():with_silent():with_desc("buffer: Goto buffer 9"),
46+
47+
-- Plugin: smart-splits.nvim
48+
["n|<A-h>"] = map_cu("SmartResizeLeft"):with_silent():with_noremap():with_desc("window: Resize -3 horizontally"),
49+
["n|<A-j>"] = map_cu("SmartResizeDown"):with_silent():with_noremap():with_desc("window: Resize -3 vertically"),
50+
["n|<A-k>"] = map_cu("SmartResizeUp"):with_silent():with_noremap():with_desc("window: Resize +3 vertically"),
51+
["n|<A-l>"] = map_cu("SmartResizeRight"):with_silent():with_noremap():with_desc("window: Resize +3 horizontally"),
52+
["n|<C-h>"] = map_cu("SmartCursorMoveLeft"):with_silent():with_noremap():with_desc("window: Focus left"),
53+
["n|<C-j>"] = map_cu("SmartCursorMoveDown"):with_silent():with_noremap():with_desc("window: Focus down"),
54+
["n|<C-k>"] = map_cu("SmartCursorMoveUp"):with_silent():with_noremap():with_desc("window: Focus up"),
55+
["n|<C-l>"] = map_cu("SmartCursorMoveRight"):with_silent():with_noremap():with_desc("window: Focus right"),
56+
["n|<leader>Wh"] = map_cu("SmartSwapLeft"):with_silent():with_noremap():with_desc("window: Move window leftward"),
57+
["n|<leader>Wj"] = map_cu("SmartSwapDown"):with_silent():with_noremap():with_desc("window: Move window downward"),
58+
["n|<leader>Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window upward"),
59+
["n|<leader>Wl"] = map_cu("SmartSwapRight"):with_silent():with_noremap():with_desc("window: Move window rightward"),
2460
}
2561

2662
bind.nvim_load_mapping(plug_map)

lua/modules/plugins/editor.lua

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ editor["nvim-pack/nvim-spectre"] = {
8888
lazy = true,
8989
cmd = "Spectre",
9090
}
91-
editor["mrjones2014/smart-splits.nvim"] = {
92-
lazy = true,
93-
event = { "CursorHoldI", "CursorHold" },
94-
config = require("editor.splits"),
95-
}
9691

9792
----------------------------------------------------------------------
9893
--  :treesitter related plugins --

lua/modules/plugins/ui.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ ui["folke/paint.nvim"] = {
5151
event = { "CursorHold", "CursorHoldI" },
5252
config = require("ui.paint"),
5353
}
54+
ui["mrjones2014/smart-splits.nvim"] = {
55+
lazy = true,
56+
event = { "CursorHoldI", "CursorHold" },
57+
config = require("ui.splits"),
58+
}
5459
ui["folke/todo-comments.nvim"] = {
5560
lazy = true,
5661
event = { "CursorHold", "CursorHoldI" },

0 commit comments

Comments
 (0)