aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-25 03:09:13 -0400
committerzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-25 03:09:13 -0400
commit2403f80945d76490c91a7be82dcb4aa3db27a929 (patch)
tree6b3bcd8f833adcebeb56156267bb6cf64665e58e
parentchange default horizontal mapping (diff)
dramatically simplify setting mappings in setup
-rw-r--r--README.md6
-rw-r--r--lua/nvterm/init.lua12
2 files changed, 10 insertions, 8 deletions
diff --git a/README.md b/README.md
index eb51f1a..c1188f8 100644
--- a/README.md
+++ b/README.md
@@ -42,9 +42,9 @@ require("nvterm").setup({
},
mappings = {
toggle = {
- { '<A-i>', function () terminal.new_or_toggle('float') end },
- { '<A-h>', function () terminal.new_or_toggle('horizontal') end },
- { '<A-v>', function () terminal.new_or_toggle('vertical') end },
+ float = "<A-i>",
+ horizontal = "<A-h>",
+ vertical = "<A-v>",
}
}
})
diff --git a/lua/nvterm/init.lua b/lua/nvterm/init.lua
index 7152426..47596cb 100644
--- a/lua/nvterm/init.lua
+++ b/lua/nvterm/init.lua
@@ -24,9 +24,9 @@ local defaults = {
},
mappings = {
toggle = {
- { '<A-i>', function () terminal.new_or_toggle('float') end },
- { '<A-h>', function () terminal.new_or_toggle('horizontal') end },
- { '<A-v>', function () terminal.new_or_toggle('vertical') end },
+ float = "<A-i>",
+ horizontal = "<A-h>",
+ vertical = "<A-v>",
}
}
}
@@ -53,8 +53,10 @@ end
local create_mappings = function (mappings)
local opts = { noremap = true, silent = true }
- for _, mapping in ipairs(mappings.toggle) do
- vim.keymap.set({'n', 't'}, mapping[1], mapping[2], opts)
+ for type, mapping in ipairs(mappings.toggle) do
+ vim.keymap.set({'n', 't'}, mapping, function ()
+ terminal.new_or_toggle(type)
+ end, opts)
end
end