aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/keybinds.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/keybinds.lua')
-rw-r--r--.config/nvim/lua/keybinds.lua39
1 files changed, 29 insertions, 10 deletions
diff --git a/.config/nvim/lua/keybinds.lua b/.config/nvim/lua/keybinds.lua
index c82587d..0846a1c 100644
--- a/.config/nvim/lua/keybinds.lua
+++ b/.config/nvim/lua/keybinds.lua
@@ -1,7 +1,8 @@
-vim.g.mapleader = " "
+local telescope = require('telescope.builtin')
+local wk = require("which-key")
+local nt_api = require("nvim-tree.api")
-vim.api.nvim_set_keymap("n", "<Leader>n", ":NvimTreeToggle<CR>",
- { noremap = true; silent = true })
+vim.g.mapleader = " "
vim.api.nvim_command("nnoremap <A-j> :m .+1<CR>==")
vim.api.nvim_command("nnoremap <A-k> :m .-2<CR>==")
@@ -10,14 +11,16 @@ 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.api.nvim_command(
- "nnoremap <buffer> <Leader><CR> :lua vim.lsp.buf.code_action()<CR>")
-vim.api.nvim_command("nnoremap <buffer> <Leader>, :TroubleToggle<CR>")
+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.api.nvim_set_keymap("n", "<Leader>f", ":Telescope find_files<CR>",
- { noremap = true; silent = true })
-vim.api.nvim_set_keymap("n", "<Leader><TAB>", ":Telescope buffers<CR>",
- { noremap = true; silent = true })
+vim.keymap.set("n", "<Leader>f", telescope.find_files)
+vim.keymap.set("n", "<Leader><TAB>", telescope.buffers)
+
+vim.api.nvim_command("nnoremap <buffer> <Leader>, :TroubleToggle<CR>")
vim.keymap.set("n", "<Leader>[", require("ufo").openAllFolds)
vim.keymap.set("n", "<Leader>]", require("ufo").closeAllFolds)
@@ -25,3 +28,19 @@ vim.keymap.set("n", "<Leader>r", require("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";
+}, {
+ prefix = "<leader>";
+});
+