aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/keybinds.lua
blob: 8be4c7f2df355bc43a79702c574381ddfcbe2b86 (plain) (blame)
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
local telescope = require("telescope.builtin")
local wk = require("which-key")
local ufo = require("ufo")
local renamer = require("renamer")
local nt_api = require("nvim-tree.api")

vim.g.mapleader = " "

vim.api.nvim_command("nnoremap <A-j> :m .+1<CR>==")
vim.api.nvim_command("nnoremap <A-k> :m .-2<CR>==")
vim.api.nvim_command("inoremap <A-k> <Esc>:m .-2<CR>==gi")
vim.api.nvim_command("inoremap <A-j> <Esc>:m .+1<CR>==gi")
vim.api.nvim_command("vnoremap <A-j> :m '>+1<CR>gv=gv")
vim.api.nvim_command("vnoremap <A-k> :m '<-2<CR>gv=gv")

vim.keymap.set("n", "<Leader>n", nt_api.tree.toggle)
vim.keymap.set("n", "<Leader><CR>", vim.lsp.buf.code_action)
vim.keymap.set("n", "<Leader>K", vim.lsp.buf.hover)
vim.keymap.set("n", "<Leader>D", vim.lsp.buf.definition)
vim.keymap.set("n", "<Leader>F", vim.lsp.buf.formatting)
vim.keymap.set("n", "<Leader>d", vim.diagnostic.open_float)

vim.keymap.set("n", "<Leader>f", telescope.find_files)
vim.keymap.set("n", "<Leader><TAB>", telescope.buffers)

vim.keymap.set("n", "<Leader>m", ":MinimapToggle<CR>")
vim.keymap.set("n", "<Leader>,", ":TroubleToggle<CR>")
vim.keymap.set("n", "<Leader>t", ":belowright split | resize 5 | terminal<CR>")

vim.keymap.set("n", "<Leader>[", ufo.openAllFolds)
vim.keymap.set("n", "<Leader>]", ufo.closeAllFolds)
vim.keymap.set("n", "<Leader>r", renamer.rename)

vim.opt.whichwrap = "<,>,h,l,[,]"

wk.register({
	["<CR>"] = "Quick Action";
	["K"] = "Hover";
	["D"] = "Definition";
	["F"] = "Format";
	["f"] = "Find files";
	["<TAB>"] = "Show buffers";
	[","] = "Show errors";
	["["] = "Open folds";
	["]"] = "Close folds";
	["r"] = "Rename";
	["n"] = "Show file tree";
	["m"] = "Toggle Minimap";
	["d"] = "Show diagnostics";
	["t"] = "Open terminal";
}, { prefix = "<leader>" });