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

123 lines
4.2 KiB
Lua
Raw Normal View History

2022-09-19 20:32:50 +02:00
-- local map = vim.api.nvim_set_keymap
local map = vim.keymap.set
local g = vim.g
2022-09-19 20:32:50 +02:00
local saga = require("lspsaga")
saga.init_lsp_saga()
2022-05-03 19:28:52 +02:00
local options = { noremap = true, silent = true }
2022-04-25 16:23:14 +02:00
local remap = { noremap = false }
g.mapleader = " "
2022-09-19 20:32:50 +02:00
map("n", "<C-o>", ":Telescope find_files<CR>", options)
2022-05-03 19:28:52 +02:00
map("n", "<C-f>", ":lua require'telescope.builtin'.live_grep{ cwd = vim.fn.getcwd() }<CR>", options)
2022-10-24 15:24:37 +02:00
-- map("n", "<C-p>", ":Telescope command_center<CR>", options)
2022-09-02 16:15:54 +02:00
map("n", "<Leader><Leader>", "za", remap)
2022-06-09 19:29:23 +02:00
2021-10-27 20:37:42 +02:00
-- LSP Functionality
2022-06-09 19:29:23 +02:00
map("n", "<Leader>n", ":lua vim.diagnostic.goto_next()<CR>", options)
map("n", "<Leader>p", ":lua vim.diagnostic.goto_prev()<CR>", options)
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", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", options)
2022-09-19 20:32:50 +02:00
map("n", "K", "<cmd>Lspsaga hover_doc<CR>", { silent = true })
map("n", "<leader>o", "<cmd>LSoutlineToggle<CR>", { silent = true })
map("n", "<leader>e", "<cmd>Lspsaga show_cursor_diagnostics<CR>", { silent = true })
map("n", "<Leader>rn", "<cmd>Lspsaga rename<CR>", options)
map({ "n", "v" }, "<leader>c", "<cmd>Lspsaga code_action<CR>", { silent = true })
map({ "n", "v" }, "gr", "Lspsaga lsp_finder<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
2022-08-23 14:58:15 +02:00
-- DAP Functionality
map("n", "<Leader>b", ":lua require('dap').toggle_breakpoint()", options)
2022-09-19 20:32:50 +02:00
-- Test Functionality
map("n", "tt", ":lua require('neotest').run.run()<CR>", options)
map("n", "to", ":lua require('neotest').summary.open()<CR>", options)
2022-10-24 15:24:37 +02:00
map({ "n", "v" }, "+", "<cmd>:Boole increment<CR>", options)
map({ "n", "v" }, "-", "<cmd>:Boole decrement<CR>", options)
-- 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)
2022-04-15 14:52:17 +02:00
2022-05-13 19:19:05 +02:00
map("n", "<Leader>1", "1gt", options)
map("n", "<Leader>2", "2gt", options)
map("n", "<Leader>3", "3gt", options)
map("n", "<Leader>4", "4gt", options)
map("n", "<Leader>0", ":tablast<CR>", options)
2022-09-19 20:32:50 +02:00
map("n", "m", ":lua require('harpoon.mark').add_file()<CR>", options)
2022-09-02 16:15:54 +02:00
-- Navigate Files
map("n", "<S-t>", ":Telescope harpoon marks<CR>", options)
2022-05-13 19:19:05 +02:00
-- Handling Splits
map("n", "<C-w>h", ":sp<CR>", remap) -- horizontal
map("n", "<C-w>v", ":vs<CR>", remap) -- vertical
2022-04-09 19:38:57 +02:00
-- Browser like next/previous
2022-08-23 14:58:15 +02:00
map("n", "<A-Left>", ":bprevious<CR>", options)
map("n", "<A-Right>", ":bnext<CR>", options)
2022-04-23 03:41:04 +02:00
-- Backspace Delete like Browser
2022-08-23 14:58:15 +02:00
map("i", "<C-H>", "<Esc>dbxi", options)
2022-04-23 03:41:04 +02:00
2022-04-25 16:23:14 +02:00
-- Copy visual selection to keyboard
map("v", "Y", '"+y', options)
2022-01-26 20:42:58 +01:00
map("n", "<Leader>k", "{", options)
map("n", "<Leader>j", "}", options)
2021-11-17 13:57:13 +01:00
2022-05-13 19:19:05 +02:00
-- I dont use macros at the moment, can disable this if i want to
2022-06-09 19:29:23 +02:00
-- map('v', 'Q', 'q', {})
-- map('v', 'Q', 'q', {})
-- map('n', 'q', '<nop>', {})
-- map('n', 'q', '<nop>', {})
2022-04-25 16:23:14 +02:00
2021-12-18 14:41:37 +01:00
-- Move lines vscode style
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)
2022-01-26 20:42:58 +01:00
map("n", "<A-S-k>", "YP", options)
map("n", "<A-S-j>", "Yp", 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
2022-08-23 14:58:15 +02:00
map("n", "<C-->", ":vsplit<CR>", options)
map("n", "<C-|>", ":split<CR>", options)
2022-04-09 19:38:57 +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
2022-10-24 15:24:11 +02:00
map("n", "<Leader>r", ":SnipRun<CR>", options)
2022-10-24 15:24:37 +02:00
map("v", "<Leader>r", ":'<,'>SnipRun<CR>", options)
2021-09-06 13:29:42 +02:00
-- Close on q
map("n", "<Leader>q", "<Esc>:q<CR>", options)
2022-05-13 19:19:05 +02:00
map("n", "<Leader><C-q>", "<Esc>:qall<CR>", options)
-- Open Nerdtree
2022-03-28 14:12:36 +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)