diff options
author | sinanmohd <sinan@firemail.cc> | 2023-10-04 09:01:23 +0530 |
---|---|---|
committer | sinanmohd <sinan@firemail.cc> | 2023-10-04 09:01:23 +0530 |
commit | 139e9754b78a1119b61f45a798c2d265e0b0308c (patch) | |
tree | 81255ab6c6839b0771d1c4e9c641886f63879ead | |
parent | ce75801ca22f9b616f307a3b4849b4b690db43f5 (diff) |
config/nvim: init table_merge
-rw-r--r-- | .config/nvim/init.lua | 15 |
1 files changed, 13 insertions, 2 deletions
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", "<leader>" .. lhs, rhs, opts) end |