aboutsummaryrefslogblamecommitdiff
path: root/.config/nvim/lua/keybinds.lua
blob: b01771629f003fff900296bab94d1579e7db9234 (plain) (tree)
1
2
3
4
5
6
7
                                              
                               
                          
                                       
                                
 
                     







                                                          


                                                            
                                                    
                                                           
                                                            
 

                                                       

                                                           
                                                                
 
                                                      

                                                              
                                                      
                                                                               

                                          
 

                                                   
                                                    
 




                                                                           

                                 



                                  
                          







                                   
                                 

                               
                                   
                                

                            

                                  
                            
 
local telescope = require("telescope.builtin")
local wk = require("which-key")
local ufo = require("ufo")
local nt_api = require("nvim-tree.api")
local spider = require("spider")

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>F", vim.lsp.buf.format)
vim.keymap.set("n", "<Leader>d", vim.diagnostic.open_float)
vim.keymap.set("n", "<Leader>J", vim.lsp.buf.signature_help)

vim.keymap.set("n", "<Leader>f", telescope.find_files)
vim.keymap.set("n", "<Leader><TAB>", telescope.buffers)
vim.keymap.set("n", "<Leader>D", telescope.lsp_definitions)
vim.keymap.set("n", "<Leader>R", telescope.lsp_references)
vim.keymap.set("n", "<Leader>S", telescope.lsp_document_symbols)

vim.keymap.set("n", "<Leader>m", ":MinimapToggle<CR>")
vim.keymap.set("n", "<Leader>b", ":Gitsigns blame_line<CR>")
vim.keymap.set("n", "<Leader>h", ":Gitsigns preview_hunk<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>s", ":w<CR>")
vim.keymap.set("n", "<Leader>q", ":q<CR>")

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

vim.keymap.set({ "n"; "o"; "x" }, "W", function() spider.motion("w") end)
vim.keymap.set({ "n"; "o"; "x" }, "E", function() spider.motion("e") end)
vim.keymap.set({ "n"; "o"; "x" }, "B", function() spider.motion("b") end)
vim.keymap.set({ "n"; "o"; "x" }, "gE", function() spider.motion("ge") end)

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

wk.register({
	["<CR>"] = "Quick Action";
	["K"] = "Hover";
	["D"] = "Definition";
	["S"] = "Symbols";
	["F"] = "Format";
	["f"] = "Find files";
	["<TAB>"] = "Show buffers";
	[","] = "Show errors";
	["["] = "Open folds";
	["]"] = "Close folds";
	["r"] = "Rename";
	["n"] = "Show file tree";
	["m"] = "Toggle Minimap";
	["b"] = "Blame line";
	["h"] = "Preview hunk";
	["d"] = "Show diagnostics";
	["t"] = "Open terminal";
	["s"] = "Save file";
	["q"] = "Quit";
	["R"] = "Show References";
	["J"] = "Signature help";
}, { prefix = "<leader>" });