-
Notifications
You must be signed in to change notification settings - Fork 0
/
keymaps.lua
327 lines (325 loc) · 14.5 KB
/
keymaps.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
local hydra = require("hydra")
local cmd = require("hydra.keymap-util").cmd
hydra({
name = "Search Commands",
mode = {"n", "v"},
hint = [[
Search Commands
^
_d_: Search Directory _w_: Search with highlighted word
_/_: Search File
^
^ ^ _q_/_<Esc>_: Exit Hydra
]],
config = {
color = 'teal',
invoke_on_body = true,
hint = {
type = 'window',
position = 'bottom',
border = 'rounded',
show_name = true
}
},
body = 'f',
heads = {
{"d", cmd 'lua require("spectre").open()<CR>', {desc = "Search", silent = true}},
{"w", cmd 'lua require("spectre").open_visual({select_word=true})<CR>', {desc = "Search word", silent = true}},
{"/", cmd 'lua require("spectre").open_file_search()<CR>', {desc = "Search File", silent = true}},
{"q", nil, {desc = "quit", exit = true, nowait = true}},
{"<Esc>", nil, {desc = "quit", exit = true, nowait = true}}
}
})
hydra({
name = "Repl Commands",
mode = {"n", "i"},
hint = [[
Repl Commands
^
_<C-z>_: Open Language Shell
_<C-t>_: Scratch Pad
_<C-s>_: Send file to repl
_<C-g>_: Restart Repl
^
_<C-q>_/_<Esc>_: Exit Hydra
]],
config = {
color = "pink",
invoke_on_body = true,
hint = {
type = "window",
position = "top-right",
border = "rounded",
show_name = true
},
},
body = "<C-e>",
heads = {
{"<C-z>", cmd "IronRepl", {desc = "Language Shell", silent = true}},
{"<C-t>", function()
local filetype = vim.api.nvim_buf_get_option(0, 'filetype')
if not filetype or filetype:len() == 0 then
filetype = 'lua'
end
require("iron.core").repl_for(filetype)
end,
{desc = "Buffer as Repl Scratch pad", silent = true}
},
{"<C-g>", function()
require("iron.core").repl_restart()
end,
{desc = "Restarts Repl", silent = true}
},
{"<C-s>", function()
local filetype = vim.api.nvim_buf_get_option(0, 'filetype')
if not filetype or filetype:len() == 0 then
filetype = 'lua'
end
if vim.api.nvim_buf_get_name(0):len() > 0 then
-- Save the file
vim.api.nvim_command('write')
end
require("iron.core").send_file(filetype)
end,
{desc = "Writes current file to repl", silent = true}
},
{"<C-q>", nil, {desc = "quit", exit = true, nowait = true}},
{"<Esc>", nil, {desc = "quit", exit = true, nowait = true}}
}
})
hydra({
name = "Quick/Common Commands",
mode = {"n"},
hint = [[
Quick/Common Commands
^
_f_: Show Filesystem _t_: Show Terminal (float) _x_: Open Quickfix
_s_: Buffer Fuzzy Search _'_: Open Symbols Outline _o_: Open Horizontal Terminal
_p_: Open Vertical Terminal _h?_: Show Help Tags _c?_: Show Vim Commands
_m?_: Show Man Pages
^
^ ^ _q_/_<Esc>_: Exit Hydra
]],
config = {
color = 'teal',
invoke_on_body = true,
hint = {
type = "window",
position = "bottom",
border = "rounded",
show_name = true,
}
},
body = "t",
heads = {
{"f", cmd 'Neotree filesystem reveal right', {desc = "Opens Neotree File Explorer", silent = true}},
{"h?", cmd "Telescope help_tags", {desc = "Open Help Tags", silent = true}},
{"c?", cmd "Telescope commands", {desc = "Open Available Telescope Commands", silent = true}},
{"s", cmd "Telescope current_buffer_fuzzy_find skip_empty_lines=true", {desc = "Fuzzy find in current buffer", silent = true}},
{"'", cmd "AerialToggle!", {desc = "Opens Symbols Outline", exit = true, silent = true}},
-- {"k?", ":lua require('telescope.builtin').keymaps()<CR>", {desc = "Open Neovim Keymaps", silent = true}},
{"m?", cmd "Telescope man_pages", {desc = "Opens Man Pages", silent = true}},
{"x", cmd "copen", {desc = "Opens Quickfix", silent = true}},
{"t", cmd "CFloatTerm", {desc = "Floating Term", silent = true}},
{"o", cmd "CSplitTerm horizontal", {desc = "Horizontal Term", silent = true}},
{"p", cmd "CSplitTerm vertical", {desc = "Vertical Term", silent = true}},
{"q", nil, {desc = "quit", exit = true, nowait = true}},
{"<Esc>", nil, {desc = "quit", exit = true, nowait = true}}
}
})
hydra({
name = "Navigation Commands",
mode = {"n"},
config = {
color = "red",
invoke_on_body = true,
hint = {
type = "window",
position = "top",
border = "rounded",
show_name = true,
}
},
hint = [[
Navigation Commands
^
_<Left>_: Resize Window Left _<Right>_: Resize Window Right _<Up>_: Resize Window Up _<Down>_: Resize Window Down
_u_: Move current tab left _i_: Move current tab right _z_: Maximize current pane
^
^ ^ _q_/_<Esc>_: Exit Hydra
]],
body = "<C-Space>",
heads = {
{"<Left>", cmd "lua require('smart-splits').resize_left()", {desc = "Resize Pane/Window Left", silent = true}},
{"<Right>", cmd "lua require('smart-splits').resize_right()", {desc = "Resize Pane/Window Right", silent = true}},
{"<Up>", cmd "lua require('smart-splits').resize_up()", {desc = "Resize Pane/Window Up", silent = true}},
{"<Down>", cmd "lua require('smart-splits').resize_down()", {desc = "Resize Pane/Window Down", silent = true}},
{"u", "<Plug>(cokeline-switch-prev)", {desc = "Move current tab left", silent = true}},
{"i", "<Plug>(cokeline-switch-next)", {desc = "Move current tab right", silent = true}},
{"z", cmd "lua require('maximize').toggle()", {desc = "Maximize current pane", exit = true, silent = true}},
{"q", nil, {desc = "quit", exit = true, nowait = true}},
{"<Esc>", nil, {desc = "quit", exit = true, nowait = true}}
}
})
hydra({
name = "Terminal Commands",
mode = {"t"},
config = {
color = "red",
invoke_on_body = true,
hint = {
type = "window",
position = "top",
border = "rounded",
show_name = true
},
},
hint = [[
Terminal Commands
^
_<Left>_: Resize Window Left _<Right>_: Resize Window Right _<Up>_: Resize Window Up _<Down>_: Resize Window Down
_h_: Move Focus Left _j_: Move Focus Down _k_: Move Focus Up _l_: Move Focus Right
_z_: Maximize current pane _<C-Space>_: Escape Terminal Mode
^
^ ^ _q_/_<Esc>_: Exit Hydra
]],
body = "<C-Space>",
heads = {
{"<Left>", cmd "lua require('smart-splits').resize_left()i", {desc = "Resize Pane/Window Left", silent = true}},
{"<Right>", cmd "lua require('smart-splits').resize_right()", {desc = "Resize Pane/Window Right", silent = true}},
{"<Up>", cmd "lua require('smart-splits').resize_up()", {desc = "Resize Pane/Window Up", silent = true}},
{"<Down>", cmd "lua require('smart-splits').resize_down()", {desc = "Resize Pane/Window Down", silent = true}},
{"h", cmd "lua require('smart-splits').move_cursor_left()", {desc = "Move Focus Left", exit = true, silent = true}},
{"j", cmd "lua require('smart-splits').move_cursor_down()", {desc = "Move Focus Down", exit = true, silent = true}},
{"k", cmd "lua require('smart-splits').move_cursor_up()", {desc = "Move Focus Up", exit = true, silent = true}},
{"l", cmd "lua require('smart-splits').move_cursor_right()",{desc = "Move Focus Right", exit = true, silent = true}},
{"z", cmd "lua require('maximize').toggle()", {desc = "Maximize current pane", exit = true, silent = true}},
{"<C-Space>", "<C-\\><C-n>", {desc = "Escape Terminal Mode", exit = true}},
{"q", nil, {desc = "quit", exit = true, nowait = true}},
{"<Esc>", nil, {desc = "quit", exit = true, nowait = true}}
}
})
hydra({
name = "LSP Mode",
mode = {"n"},
config = {
color = "pink",
invoke_on_body = true,
hint = {
type = "window",
position = "bottom-right",
border = "rounded",
show_name = true
},
},
hint = [[
LSP
^
Common Actions
- _h_: Show Hover Doc
- _f_: Format Buffer
- _a_: Code Actions
- _s_: Jump to Definition
^
Help
- _e_: Show Declerations
- _D_: Show Type Definition
- _j_: Show Sig Help
- _o_: Show Implementation
- _r_: Show References
^
_;_/_q_/_<Esc>_: Exit Hydra
]],
body = ";",
heads = {
{"s", vim.lsp.buf.definition, {desc = "Jump to Definition", silent = true}},
{"h", require("hover").hover, {desc = "Show Hover Doc", silent = true}},
{"o", vim.lsp.buf.implementation, {desc = "Show Implementations", silent = true}},
{"j", vim.lsp.buf.signature_help, {desc = "Show Sig Help", silent = true}},
{"r", vim.lsp.buf.references, {desc = "Show References", silent = true}},
{"f", function() vim.lsp.buf.format({ async = true }) end, {desc = "Format Buffer", silent = true}},
{"a", vim.lsp.buf.code_action, {desc = "Show Code Actions", silent = true}},
{"D", vim.lsp.buf.type_definition, {desc = "Show Type Definition", silent = true}},
{"e", vim.lsp.buf.decleration, {desc = "Show Declerations", silent = true}},
{";", nil, {desc = "quit", exit = true, nowait = true}},
{"q", nil, {desc = "quit", exit = true, nowait = true}},
{"<Esc>", nil, {desc = "quit", exit = true, nowait = true}}
}
})
hydra({
name = "DAP",
mode = {"n"},
config = {
color = "pink",
invoke_on_body = true,
hint = {
type = "window",
position = "middle-right",
border = "rounded",
show_name = true,
},
},
hint = [[
DAP
^
_d_: Toggle Breakpoint
_D_: Set Conditional Breakpoint
_c_: Continue on Break
_S_: Stop Debugger
^
_j_: Step out of code block
_k_: Step over code block
_l_: Step into code block
_L_: Launches DAP Server
^
_r_: Open Live REPL
^
_s_/_q_/_<Esc>_: Exit Hydra
]],
body = "s",
heads = {
{"d", cmd "lua require('dap').toggle_breakpoint()", {desc = "Set Breakpoint", silent = true}},
{"D", cmd "lua require('dap').set_breakpoint(vim.fn.input('Condition: '))", {desc = "Set conditional Breakpoint", silent = true}},
{"c", cmd "lua require('dap').continue()", {desc = "Continue on break", silent = true}},
{"j", cmd "lua require('dap').step_out()", {desc = "Step out of code block", silent = true}},
{"k", cmd "lua require('dap').step_over()", {desc = "Step over code block", silent = true}},
{"l", cmd "lua require('dap').step_into()", {desc = "Step into code block", silent = true}},
{"L", function()
local filetype = vim.api.nvim_buf_get_option(0, 'filetype')
local dap = require("dap")
if filetype == '' then filetype = 'nil' end
if dap and dap.launch_server and dap.launch_server[filetype] then
dap.launch_server[filetype]()
else
print(string.format("No DAP Launch server configured for filetype %s", filetype))
end
end, {desc = "Launches Dap Server"}},
{"r", cmd "lua require('dap').repl.open()", {desc = "Open Live REPL", silent = true}},
{"S", cmd "lua require('dap').terminate({},{terminateDebuggee = true}, function() require('dap').close() end)", {desc = "Stop Debugger", exit = true}},
{"s", nil, {desc = "quit", exit = true, nowait = true}},
{"q", nil, {desc = "quit", exit = true, nowait = true}},
{"<Esc>", nil, {desc = "quit", exit = true, nowait = true}}
}
})
vim.keymap.set('', '<Esc>', "<ESC>:noh<CR>:lua import('notify', function(_) _.dismiss() end)<CR>", {silent = true})
vim.keymap.set('n', '<C-t>', ':CFloatTerm<CR>', {silent = true})
vim.keymap.set('t', '<C-t>', '<C-\\><C-n>:CFloatTerm<CR>', {silent = true})
vim.keymap.set('n', '<C-p>', ':CSplitTerm vertical<CR>', {silent = true})
vim.keymap.set('t', '<C-p>', '<C-\\><C-n>:CSplitTerm vertical<CR>', {silent = true})
vim.keymap.set('n', '<C-o>', ':CSplitTerm horizontal<CR>', {silent = true})
vim.keymap.set('t', '<C-o>', '<C-\\><C-n>:CSplitTerm horizontal<CR>', {silent = true})
vim.keymap.set('n', '<C-_>', ':lua require("Comment.api").toggle.linewise()<CR>', {silent = true})
vim.keymap.set('i', '<C-_>', '<ESC>:lua require("Comment.api").toggle.linewise()<CR>i', {silent = true})
vim.keymap.set('x', '<C-_>', '<ESC>:lua require("Comment.api").toggle.linewise(vim.fn.visualmode())<CR>', {silent = true})
vim.keymap.set('n', '<C-h>', ":lua require('smart-splits').move_cursor_left()<CR>",{silent = true})
vim.keymap.set('n', '<C-j>', ":lua require('smart-splits').move_cursor_down()<CR>", {silent = true})
vim.keymap.set('n', '<C-k>', ":lua require('smart-splits').move_cursor_up()<CR>", {silent = true})
vim.keymap.set('n', "<C-l>", ":lua require('smart-splits').move_cursor_right()<CR>", {silent = true})
vim.keymap.set('t', '<C-h>', "<C-\\><C-n>:lua require('smart-splits').move_cursor_left()<CR><ESC>",{silent = true})
vim.keymap.set('t', '<C-j>', "<C-\\><C-n>:lua require('smart-splits').move_cursor_down()<CR><ESC>", {silent = true})
vim.keymap.set('t', '<C-k>', "<C-\\><C-n>:lua require('smart-splits').move_cursor_up()<CR><ESC>", {silent = true})
vim.keymap.set('t', "<C-l>", "<C-\\><C-n>:lua require('smart-splits').move_cursor_right()<CR><ESC>", {silent = true})
vim.keymap.set("n", "<A-h>", "<Plug>(cokeline-focus-prev)", {silent = true})
vim.keymap.set("n", "<A-l>", "<Plug>(cokeline-focus-next)", {silent = true})
-- vim.keymap.set("n", '/', ':lua require("searchbox").incsearch({modifier = "disabled"})<CR>', {silent = true})
-- vim.keymap.set("n", 'r', ':lua require("searchbox").replace({confirm = "menu"})<CR>', {silent = true})