From 57e115339d00a2a8afe09dba6f83009cc5a02e99 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Mon, 10 Apr 2023 16:38:26 -0300 Subject: nvim update, semi-refactor --- .config/nvim/lua/keymaps.lua | 82 ++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 56 deletions(-) mode change 100755 => 100644 .config/nvim/lua/keymaps.lua (limited to '.config/nvim/lua/keymaps.lua') diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua old mode 100755 new mode 100644 index 16de10f..4c09fd2 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -1,68 +1,38 @@ vim.g.mapleader = " " -local function keymap(mode, lhs, rhs, opts) - opts = opts or { noremap = true, silent = true } - vim.keymap.set(mode, lhs, rhs, opts) -end -keymap('n', '', - function() require('luasnip').jump(1) end, - {noremap = true, silent = true}) +local opts = { noremap = true, silent = true } -- Map leader + s and v/h to open split -keymap('n', 'sp', ':sp') -keymap('n', 'sv', ':vsp') +vim.keymap.set('n', 'sp', ':sp', opts) +vim.keymap.set('n', 'sv', ':vsp', opts) -keymap('n', 'q', ':q') +vim.keymap.set('n', 'q', ':q', opts) -keymap('n', '', ':mksession!nvim-session:wqa') -keymap('n', '', ':wa:mksession!nvim-session') -keymap('n', '', ':sourcenvim-session') +vim.keymap.set('n', 'y', '"+y', opts) +vim.keymap.set('n', 'd', '"+d', opts) +vim.keymap.set('n', 'p', '"+p', opts) +vim.keymap.set('n', 'Y', '"+Y', opts) +vim.keymap.set('n', 'D', '"+D', opts) +vim.keymap.set('n', 'P', '"+P', opts) -keymap('n', 'y', '"+y') -keymap('n', 'd', '"+d') -keymap('n', 'p', '"+p') -keymap('n', 'Y', '"+Y') -keymap('n', 'D', '"+D') -keymap('n', 'P', '"+P') +vim.keymap.set('v', 'y', '"+y', opts) +vim.keymap.set('v', 'd', '"+d', opts) +vim.keymap.set('v', 'p', '"+p', opts) +vim.keymap.set('v', 'Y', '"+Y', opts) +vim.keymap.set('v', 'D', '"+D', opts) +vim.keymap.set('v', 'P', '"+P', opts) -keymap('v', 'y', '"+y') -keymap('v', 'd', '"+d') -keymap('v', 'p', '"+p') -keymap('v', 'Y', '"+Y') -keymap('v', 'D', '"+D') -keymap('v', 'P', '"+P') +vim.keymap.set('n', '', 'h', opts) +vim.keymap.set('n', '', 'k', opts) +vim.keymap.set('n', '', 'j', opts) +vim.keymap.set('n', '', 'l', opts) -keymap('n', '', 'h') -keymap('n', '', 'k') -keymap('n', '', 'j') -keymap('n', '', 'l') +vim.keymap.set('n', '', ':cn', opts) +vim.keymap.set('n', '', ':cp', opts) -keymap('v', '<', '', '>gv') +vim.keymap.set('v', '<', '', '>gv', opts) -keymap('i', '', '') +vim.keymap.set('i', '', '', opts) -vim.api.nvim_create_autocmd('User', { - pattern = 'LspAttached', - desc = 'LSP Keymaps', - callback = function() - local function bufmap(mode, lhs, rhs) - keymap(mode, lhs, rhs, { silent = true, noremap = true, buffer = true }) - end - - bufmap('n', 'gD', vim.lsp.buf.declaration) - bufmap('n', 'gd', vim.lsp.buf.definition) - bufmap('n', 'K', vim.lsp.buf.hover) - bufmap('n', 'gi', vim.lsp.buf.implementation) - bufmap('n', '', vim.lsp.buf.signature_help) - bufmap('n', 'wa', vim.lsp.buf.add_workspace_folder) - bufmap('n', 'wr', vim.lsp.buf.remove_workspace_folder) - bufmap('n', 'wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end) - bufmap('n', 'D', vim.lsp.buf.type_definition) - bufmap('n', 'rn', vim.lsp.buf.rename) - bufmap('n', 'ca', vim.lsp.buf.code_action) - bufmap('n', 'gr', vim.lsp.buf.references) - bufmap('n', 'f', vim.lsp.buf.formatting) - bufmap('n', 'e', vim.diagnostic.open_float) - end -}) +vim.keymap.set('n', 'gp', require('utils').lsp_peek, opts) -- cgit v1.2.3