.dotfiles/configs/nvim/lua/keymappings.lua

74 lines
2.5 KiB
Lua
Raw Normal View History

local map = vim.api.nvim_set_keymap
local g = vim.g
2021-11-17 13:57:13 +01:00
local cmd = vim.cmd;
2021-10-06 14:48:32 +02:00
local options = {noremap = true}
local remap = {noremap = false}
g.mapleader = " "
map("n", "<C-p>", ":Telescope find_files<CR>", options)
2021-10-27 20:37:42 +02:00
map("n", "<C-f>", ":Telescope live_grep<CR>", options)
2021-10-06 14:48:32 +02:00
2021-10-27 20:37:42 +02:00
-- LSP Functionality
2021-11-17 13:57:13 +01:00
map("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", options)
map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", options)
map("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", options)
map("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", options)
map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", options)
map("n", "<Leader>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", options)
map("n", "<Leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", options)
map("n", "<Leader>c", "<cmd>lua vim.lsp.buf.code_action()<CR>", options)
2021-11-17 14:04:03 +01:00
map("n", "<Leader><C-f>", ":Format<CR>", options)
2021-11-17 13:57:13 +01:00
map("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", options)
map("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", options)
2021-11-22 18:45:07 +01:00
map("n", "<leader>t", ":TroubleToggle<CR>", remap)
2021-10-27 20:37:42 +02:00
-- Navigate Buffers
map("n", "<C-h>", "<C-w>h", options)
map("n", "<C-j>", "<C-w>j", options)
map("n", "<C-k>", "<C-w>k", options)
map("n", "<C-l>", "<C-w>l", options)
2021-11-17 13:57:13 +01:00
map("n", "Y", "yy", options)
map("n", "<Leader>k", "{",options)
map("n", "<Leader>j", "}",options)
2021-11-22 18:45:07 +01:00
map("n", "<A-j>", "<cmd>move +1<CR>", options)
map("n", "<A-k>", "<cmd>move -2<CR>", options)
map("i", "<A-j>", "<cmd>move +1<CR>", options)
map("i", "<A-k>", "<cmd>move -2<CR>", options)
2021-11-26 16:41:10 +01:00
map("v", "<A-j>", ":m '>+1<CR>gv=gv", options)
map("v", "<A-k>", ":m '<-2<CR>gv=gv", options)
2021-11-17 13:57:13 +01:00
-- Faster git merge
map("n", "<Leader>gd", ":Gvdiffsplit!<CR>", options)
map("n", "<Leader>gdl", ":diffget //3<CR>", options)
map("n", "<Leader>gdh", ":diffget //2<CR>", options)
2021-09-22 11:44:12 +02:00
-- Find file in NvimTree
2021-10-27 20:37:42 +02:00
map("n", "<Leader>f", ":NvimTreeFindFile<CR><c-w>", options)
2021-09-22 11:44:12 +02:00
-- I aint no weak boy
map("n", "<Left>", ":echo 'No Left for you'<CR><i><dw>", options)
map("n", "<Right>", ":echo 'No Right for you'<CR><dw>", options)
map("n", "<Up>", ":echo 'No Up for you'<CR><dw>", options)
map("n", "<Down>", ":echo 'No Down for you'<CR><dw>", options)
2021-09-06 13:29:42 +02:00
-- Run Requests
map("n", "<Leader>r", "<cmd>lua require('rest-nvim').run()<CR>", options)
-- Close on q
map("n", "<Leader>q", "<Esc>:q<CR>", options)
-- Open Nerdtree
2021-09-22 11:44:12 +02:00
map("n", "<C-n>", ":NvimTreeToggle<CR>", options)
-- Make ctrl+s work
map("n", "<C-s>", "<Esc>:w<CR>", options)
map("i", "<C-s>", "<Esc>:w<CR>i", options)
-- Update vim config
map("n", "<C-u>", "<Esc>:source $MYVIMRC<CR>", options)