From 139e9754b78a1119b61f45a798c2d265e0b0308c Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Wed, 4 Oct 2023 09:01:23 +0530 Subject: config/nvim: init table_merge --- .config/nvim/init.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to '.config') diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index e2cac1a..5d2494e 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -18,13 +18,24 @@ vim.wo.relativenumber = true vim.wo.signcolumn = "yes" -- [[ lib ]] +local table_merge = function (t1, t2) + t1 = t1 or {} + t2 = t2 or {} + + for k, v in pairs(t2) do + t1[k] = v + end + + return t1 +end + local map = function(mode, lhs, rhs, opts) - opts = opts or { silent = true } + opts = table_merge(opts, { silent = true }) vim.api.nvim_set_keymap(mode, lhs, rhs, opts) end local mapnl = function(lhs, rhs, opts) - opts = opts or { silent = true } + opts = table_merge(opts, { silent = true }) vim.keymap.set("n", "" .. lhs, rhs, opts) end -- cgit v1.2.3