@@ -5,15 +5,60 @@ local map_cmd = bind.map_cmd
55local map_callback = bind .map_callback
66local 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+
856local 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
0 commit comments