aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-25 03:44:31 -0400
committerzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-25 03:45:13 -0400
commit3c9c617bd33b8126b041920ea0018a4374843df1 (patch)
tree277337db34ed60edafb3932199e858b962eb9e8b
parentadd new mappings and simplify more (diff)
fix error with mappings
-rw-r--r--lua/nvterm/init.lua25
1 files changed, 15 insertions, 10 deletions
diff --git a/lua/nvterm/init.lua b/lua/nvterm/init.lua
index 253eccb..01bf487 100644
--- a/lua/nvterm/init.lua
+++ b/lua/nvterm/init.lua
@@ -54,15 +54,20 @@ local set_behavior = function(behavior)
end
end
-local create_mappings = function (mappings)
- local opts = { noremap = true, silent = true }
- vim.tbl_map(function(method)
- for type, mapping in pairs(method) do
- vim.keymap.set({'n', 't'}, mapping, function ()
- require("nvterm.terminal")[method](type)
- end, opts)
- end
- end, mappings)
+M.create_mapping = function(method, map_table, opts)
+ opts = opts or {}
+ vim.tbl_deep_extend("force", { noremap = true, silent = true }, opts)
+ for type, mapping in pairs(map_table) do
+ vim.keymap.set({'n', 't'}, mapping, function ()
+ require('nvterm.terminal')[method](type)
+ end, opts)
+ end
+end
+
+local setup_mappings = function (mappings)
+ for method, map_table in pairs(mappings) do
+ M.create_mapping(method, map_table)
+ end
end
M.setup = function (config)
@@ -75,7 +80,7 @@ M.setup = function (config)
end
end
set_behavior(config.behavior)
- create_mappings(config.mappings)
+ setup_mappings(config.mappings)
require("nvterm.terminal").init(config.terminals)
end