diff --git a/lua/chadrc.lua b/lua/chadrc.lua index cd1df7a..84d5690 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -101,8 +101,9 @@ local M = { }, toggleterm = { toggle_window = "w", - toggle_right = "v", - toggle_bot = "h" + toggle_vert = "v", + toggle_hori = "h", + hide_term = "JK" }, insert_nav = { forward = "", diff --git a/lua/mappings.lua b/lua/mappings.lua index 77fb1ca..b0624ef 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -49,14 +49,14 @@ M.toggleterm = function() local m = user_map.toggleterm -- Open terminals - map("n", m.toggle_window, ":execute v:count . 'ToggleTerm direction=window' ", opt) - map("n", m.toggle_right, ":execute v:count . 'ToggleTerm direction=vertical' ", opt) - map("n", m.toggle_bot, ":execute v:count . 'ToggleTerm direction=horizontal' ", opt) + map("n", m.toggle_window, ":lua termW:toggle() ", opt) + map("n", m.toggle_vert, ":lua termV:toggle() ", opt) + map("n", m.toggle_hori, ":lua termH:toggle() ", opt) - -- 'Un' toggle a term from within terminal edit mode - map("t", m.toggle_window, " :ToggleTerm ", opt) - map("t", m.toggle_right, " :ToggleTerm ", opt) - map("t", m.toggle_bot, " :ToggleTerm ", opt) + -- toggle(HIDE) a term from within terminal edit mode + map("t", m.hide_term, " :ToggleTerm ", opt) + map("t", m.hide_term, " :ToggleTerm ", opt) + map("t", m.hide_term, " :ToggleTerm ", opt) end M.truezen = function() diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index 174e544..a3f7722 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -31,3 +31,17 @@ toggleterm.setup { } } } + +local Terminal = require("toggleterm.terminal").Terminal + +_G.termW = Terminal:new { + direction = "window", +} + +_G.termV = Terminal:new { + direction = "vertical", +} + +_G.termH = Terminal:new { + direction = "horizontal", +}