From 800df5de3736aeba46bc1484743046ae7229b547 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 31 Oct 2021 00:16:10 +0100 Subject: [PATCH] refactor(nvim): add a local map function alias --- nvim/.config/nvim/lua/opdavies/init.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/nvim/.config/nvim/lua/opdavies/init.lua b/nvim/.config/nvim/lua/opdavies/init.lua index e9e690d..2892e73 100644 --- a/nvim/.config/nvim/lua/opdavies/init.lua +++ b/nvim/.config/nvim/lua/opdavies/init.lua @@ -36,27 +36,29 @@ vim.o.wrap = true vim.opt.clipboard:append 'unnamedplus' +local map = vim.api.nvim_set_keymap + local options = { noremap = true } -vim.api.nvim_set_keymap('n', 'so', ':so ~/.config/nvim/init.vim', options) +map('n', 'so', ':so ~/.config/nvim/init.vim', options) -- Make the current file executable -vim.api.nvim_set_keymap('n', 'x', ':!chmod +x %', options) +map('n', 'x', ':!chmod +x %', options) -- Yank from the current column to the end of the line -vim.api.nvim_set_keymap('n', 'Y', 'yg$', options) +map('n', 'Y', 'yg$', options) -- Keep things centred -vim.api.nvim_set_keymap('n', 'n', 'nzzzv', options) -vim.api.nvim_set_keymap('n', 'N', 'Nzzzv', options) +map('n', 'n', 'nzzzv', options) +map('n', 'N', 'Nzzzv', options) -- Remove arrow keys -vim.api.nvim_set_keymap('v', '', '', options) -vim.api.nvim_set_keymap('v', '', '', options) -vim.api.nvim_set_keymap('v', '', '', options) -vim.api.nvim_set_keymap('v', '', '', options) +map('v', '', '', options) +map('v', '', '', options) +map('v', '', '', options) +map('v', '', '', options) -vim.api.nvim_set_keymap('n', 'k', ':nohlsearch', options) +map('n', 'k', ':nohlsearch', options) require('packer').startup(function() -- Utilities