diff options
author | zbirenbaum <zacharyobirenbaum@gmail.com> | 2022-04-25 04:39:51 -0400 |
---|---|---|
committer | zbirenbaum <zacharyobirenbaum@gmail.com> | 2022-04-25 04:44:34 -0400 |
commit | 8c435a2cf81365d1fcc8628133f83d482a333c82 (patch) | |
tree | 803000aa03d0ea57318c48906e032cc880cb9969 /lua | |
parent | add enable flag for new mappings (diff) |
finish shortcut method and update readme
Diffstat (limited to 'lua')
-rw-r--r-- | lua/nvterm/init.lua | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lua/nvterm/init.lua b/lua/nvterm/init.lua index 9a1d930..ac4d91e 100644 --- a/lua/nvterm/init.lua +++ b/lua/nvterm/init.lua @@ -70,26 +70,24 @@ 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.mappings.new = config.enable_new_mappings or nil + config = map_config_shortcuts(config) + config.mappings.new = config.enable_new_mappings and config.mappings.new or nil setup_mappings(config.mappings) require("nvterm.terminal").init(config.terminals) end |