22-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
33-- Add any additional keymaps here
44
5+ -- custom keymaps
6+ -- for conciseness
7+ local keymap = vim .keymap
8+ local wk = require (" which-key" )
9+
10+ -- helper for keymaps
11+ local function map (mode , l , r , opts )
12+ keymap .set (mode , l , r , opts )
13+ end
14+
15+ local function nmap (l , r , opts )
16+ map (" n" , l , r , opts )
17+ end
18+
19+ local function vmap (l , r , opts )
20+ map (" v" , l , r , opts )
21+ end
22+
23+ local function unmap (mode , l )
24+ keymap .del (mode , l )
25+ end
26+
27+ local function nunmap (l )
28+ unmap (" n" , l )
29+ end
30+
31+ local function vunmap (l )
32+ unmap (" v" , l )
33+ end
34+
35+ local function wunmap (l )
36+ nunmap (" <leader>" .. l )
37+ end
38+
39+ local function wgroup (groups )
40+ for key , value in pairs (groups ) do
41+ wk .add ({ " <leader>" .. key , group = value })
42+ end
43+ end
44+
45+ local function wmap (mode , mappings )
46+ for key , value in pairs (mappings ) do
47+ local mapping = " <leader>" .. key
48+ local command = value [1 ]
49+ local description = value [2 ]
50+
51+ wk .add ({ mapping , command , desc = description , mode = mode })
52+ end
53+ end
54+
55+ local function wnmap (mappings )
56+ wmap (" n" , mappings )
57+ end
58+
59+ local function wvmap (mappings )
60+ wmap (" v" , mappings )
61+ end
62+
563-- custom which-key mappings
664local groups = {}
765local mappings = {}
866local vmappings = {}
967
68+ -- comments
69+ nmap (" ;;" , " gcc" , { remap = true })
70+ nmap (" ;A" , " gcA" , { remap = true })
71+ nmap (" ;p" , " gcap" , { remap = true })
72+ nmap (" ;o" , " gco" , { remap = true })
73+ nmap (" ;O" , " gcO" , { remap = true })
74+ vmap (" ;" , " gc" , { remap = true })
75+
76+ -- navigation
77+ nmap (" H" , " Hzz" )
78+ nmap (" L" , " Lzz" )
79+
80+ -- navigation between window panes
81+ nmap (" <C-h>" , " <CMD>NvimTmuxNavigateLeft<CR>" )
82+ nmap (" <C-j>" , " <CMD>NvimTmuxNavigateDown<CR>" )
83+ nmap (" <C-k>" , " <CMD>NvimTmuxNavigateUp<CR>" )
84+ nmap (" <C-l>" , " <CMD>NvimTmuxNavigateRight<CR>" )
85+ nmap (" <C-Tab>" , " <CMD>NvimTmuxNavigateLastActive<CR>" )
86+ nmap (" <C-Space>" , " <CMD>NvimTmuxNavigateNext<CR>" )
87+
88+ -- navigation between buffers
89+ nmap (" <M-Right>" , " <CMD>BufferLineCycleNext<CR>" )
90+ nmap (" <M-Left>" , " <CMD>BufferLineCyclePrev<CR>" )
91+
92+ nmap (" <M-3>" , " <leader>Tf" )
93+ nmap (" <M-2>" , " <leader>Th" )
94+ nmap (" <M-1>" , " <leader>Tv" )
95+
96+ -- which-key setup
1097-- unmap things that I want to use
11- -- mappings["/"] = {} -- comment
12- -- mappings[";"] = {} -- Dashboard
13- -- mappings["b"]["b"] = {} -- previous buffer
14- -- mappings["b"]["D"] = {} -- BufferLineSortByDirectory
15- -- mappings["b"]["l"] = {} -- BufferLineCloseRight
16- -- mappings["b"]["L"] = {} -- sort by language
17- -- mappings["g"]["b"] = {} -- git new branch
18- -- mappings["g"]["l"] = {} -- git blame
19- -- mappings["g"]["L"] = {} -- git blame
20- -- mappings["bf"] = {} -- buffer find
21- -- mappings["c"] = {} -- close buffer
22- -- mappings["s"] = {} -- search
23- -- mappings["w"] = {} -- save
24- -- vmappings["/"] = {} -- comment
98+ wunmap (" `" )
99+ wunmap (" fb" )
100+ wunmap (" fc" )
101+ wunmap (" fe" )
102+ wunmap (" fE" )
103+ wunmap (" ft" )
104+ wunmap (" fT" )
105+ wunmap (" gg" )
106+ wunmap (" gG" )
107+ wunmap (" bo" )
108+ wunmap (" bl" )
109+ wunmap (" br" )
25110
26111-- set menu items
27- groups [" D" ] = " Devcontainer"
28- groups [" f" ] = " Files"
29- groups [" q" ] = " Quit"
30- groups [" /" ] = " Search"
31- groups [" w" ] = " Windows"
112+ groups [" D" ] = " +devcontainer"
113+ groups [" f" ] = " +files"
114+ groups [" /" ] = " +search"
115+ groups [" t" ] = " +terminal"
116+
117+ wgroup (groups )
32118
33119mappings [" +" ] = { " <C-a>" , " Increment Number" } -- increment
34120mappings [" -" ] = { " <C-x>" , " Decrement Number" } -- decrement
121+ mappings [" h" ] = { " <CMD>nohlsearch<CR>" , " No Highlight" }
35122
36123-- buffers operations
37124mappings [" <Tab>" ] = { " <CMD>edit #<CR>" , " Previous Active Buffer" }
38- mappings [" 0" ] = { " <CMD>NvimTreeFocus<CR>" , " Focus Explorer" }
125+ mappings [" 0" ] = {
126+ function ()
127+ require (" neo-tree.command" ).execute ({ toggle = false , dir = vim .uv .cwd () })
128+ end ,
129+ " Focus Explorer" ,
130+ }
39131mappings [" 1" ] = { " <CMD>BufferLineGoToBuffer 1<CR>" , " Select Buffer 1" }
40132mappings [" 2" ] = { " <CMD>BufferLineGoToBuffer 2<CR>" , " Select Buffer 2" }
41133mappings [" 3" ] = { " <CMD>BufferLineGoToBuffer 3<CR>" , " Select Buffer 3" }
@@ -47,16 +139,15 @@ mappings["8"] = { "<CMD>BufferLineGoToBuffer 8<CR>", "Select Buffer 8" }
47139mappings [" 9" ] = { " <CMD>BufferLineGoToBuffer 9<CR>" , " Select Buffer 9" }
48140
49141mappings [" b/" ] = { " <CMD>Telescope buffers previewer=true<CR>" , " Find" }
50- mappings [" bb" ] = { " <cmd>Telescope oldfiles<CR>" , " Open Recent File" }
51- mappings [" bd" ] = { " <CMD>BufferKill<CR>" , " Close" }
142+ mappings [" b[" ] = { " <CMD>BufferLineCycleNext<CR>" , " Previous" }
143+ mappings [" b]" ] = { " <CMD>BufferLineCyclePrev<CR>" , " Next" }
144+ mappings [" bb" ] = { " <CMD>Telescope oldfiles<CR>" , " Open Recent File" }
52145mappings [" bD" ] = { " <CMD>BufferSortByDirectory<CR>" , " Sort by Directory" }
53146mappings [" bj" ] = { " <CMD>BufferLinePick<CR>" , " Jump" }
54147mappings [" bl" ] = { " <CMD>BufferLineSortByExtension<CR>" , " Sort by Language" }
55148mappings [" bL" ] = { " <CMD>BufferLineCloseLeft<CR>" , " Close All to Left" }
56- mappings [" bM" ] = { " <CMD>BufferLineCloseLeft<CR><CMD>BufferLineCloseRight<CR>" , " Close All Other" }
57- mappings [" bn" ] = { " <CMD>BufferLineCycleNext<CR>" , " Next" }
58149mappings [" bN" ] = { " <CMD>tabnew<CR>" , " New" }
59- mappings [" bp " ] = { " <CMD>BufferLineCyclePrev <CR>" , " Previous " }
150+ mappings [" bO " ] = { " <CMD>BufferLineCloseLeft <CR><CMD>BufferLineCloseRight<CR> " , " Close All Other " }
60151mappings [" bR" ] = { " <CMD>BufferLineCloseRight<CR>" , " Close All to Right" }
61152
62153-- command
@@ -97,7 +188,7 @@ mappings["fw"] = { "<CMD>noautocmd w<CR>", "Save Current (noautocmd)" }
97188mappings [" fo" ] = { " <CMD>Oil --float .<CR>" , " Open Oil in Current Path" }
98189
99190-- git
100- mappings [" gl" ] = { " <CMD>LazyGit <CR>" , " LazyGit (float)" }
191+ mappings [" gl" ] = { " <CMD>LazyGitCurrentFile <CR>" , " LazyGit (float)" }
101192mappings [" gb" ] = { " <CMD>Gitsigns toggle_current_line_blame<CR>" , " Blame" }
102193
103194-- gitlab
@@ -154,65 +245,5 @@ mappings["ws"] = { "<CMD>split<CR>", "Split Horizontal" }
154245mappings [" wt" ] = { " <CMD>tab split<CR>" , " Send to Tab" }
155246mappings [" wv" ] = { " <CMD>vsplit<CR>" , " Split Vertical" }
156247
157- local wk = require (" which-key" )
158- for key , value in pairs (groups ) do
159- wk .add ({ " <leader>" .. key , group = value })
160- end
161-
162- for key , value in pairs (mappings ) do
163- local map = " <leader>" .. key
164- local command = value [1 ]
165- local description = value [2 ]
166-
167- wk .add ({ map , command , desc = description , mode = " n" })
168- end
169-
170- for key , value in pairs (vmappings ) do
171- local map = " <leader>" .. key
172- local command = value [1 ]
173- local description = value [2 ]
174-
175- wk .add ({ map , command , desc = description , mode = " v" })
176- end
177-
178-
179- -- custom keymaps
180- -- for conciseness
181- local keymap = vim .keymap
182-
183- -- helper for keymaps
184- local function map (mode , l , r , opts )
185- keymap .set (mode , l , r , opts )
186- end
187-
188- local function nmap (l , r , opts )
189- map (" n" , l , r , opts )
190- end
191-
192- local function vmap (l , r , opts )
193- map (" v" , l , r , opts )
194- end
195-
196- -- comments
197- nmap (" ;;" , " gcc" , { remap = true })
198- nmap (" ;A" , " gcA" , { remap = true })
199- nmap (" ;p" , " gcap" , { remap = true })
200- nmap (" ;o" , " gco" , { remap = true })
201- nmap (" ;O" , " gcO" , { remap = true })
202- vmap (" ;" , " gc" , { remap = true })
203-
204- -- navigation
205- nmap (" H" , " Hzz" )
206- nmap (" L" , " Lzz" )
207-
208- -- navigation between window panes
209- nmap (" <C-h>" , " <CMD>NvimTmuxNavigateLeft<CR>" )
210- nmap (" <C-j>" , " <CMD>NvimTmuxNavigateDown<CR>" )
211- nmap (" <C-k>" , " <CMD>NvimTmuxNavigateUp<CR>" )
212- nmap (" <C-l>" , " <CMD>NvimTmuxNavigateRight<CR>" )
213- nmap (" <C-Tab>" , " <CMD>NvimTmuxNavigateLastActive<CR>" )
214- nmap (" <C-Space>" , " <CMD>NvimTmuxNavigateNext<CR>" )
215-
216- -- navigation between buffers
217- nmap (" <M-Right>" , " <CMD>BufferLineCycleNext<CR>" )
218- nmap (" <M-Left>" , " <CMD>BufferLineCyclePrev<CR>" )
248+ wnmap (mappings )
249+ wvmap (vmappings )
0 commit comments