aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-25 04:39:51 -0400
committerzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-25 04:39:51 -0400
commitf0717aa4a157bda5b1dc128908adca4bdb7556c6 (patch)
tree2ffda6442d255bb093e4e15844d102a6c77f8e32 /lua
parentadd enable flag for new mappings (diff)
finish shortcut method and update readmedev
Diffstat (limited to 'lua')
-rw-r--r--lua/nvterm/init.lua22
1 files changed, 10 insertions, 12 deletions
diff --git a/lua/nvterm/init.lua b/lua/nvterm/init.lua
index 9a1d930..45aa254 100644
--- a/lua/nvterm/init.lua
+++ b/lua/nvterm/init.lua
@@ -70,25 +70,23 @@ local setup_mappings = function (mappings)
end
end
-local map_config_shortcuts = function (config, location, shortcut)
- for _, key in ipairs(shortcut) do
- config[key] = config[key] or {}
- vim.tbl_deep_extend("force", location[key], config[key])
- config[key] = nil
- end
- return config
-end
-
-M.setup = function (config)
- config = config and vim.tbl_deep_extend("force", defaults, config) or defaults
+local map_config_shortcuts = function (config)
local shortcuts = {
{ config.terminals.type_opts, { 'horizontal', 'vertical', 'float' } },
{ config.mappings, { 'toggle', 'new' } },
}
for _, shortcut_map in ipairs(shortcuts) do
- map_config_shortcuts(config, shortcut_map[1], shortcut_map[2])
+ for _, key in ipairs(shortcut_map[2]) do
+ shortcut_map[1][key] = vim.tbl_deep_extend("force", shortcut_map[1][key], config[key] or {})
+ end
end
+ return config
+end
+
+M.setup = function (config)
+ config = config and vim.tbl_deep_extend("force", defaults, config) or defaults
set_behavior(config.behavior)
+ config = map_config_shortcuts(config)
config.mappings.new = config.enable_new_mappings or nil
setup_mappings(config.mappings)
require("nvterm.terminal").init(config.terminals)