From 63d54926a4a80e289d4c49cda70ab7b18cfa64d2 Mon Sep 17 00:00:00 2001 From: siduck Date: Fri, 1 Apr 2022 11:47:05 +0530 Subject: [PATCH] add mappings to spawn nobufflisted terms --- lua/core/default_config.lua | 9 +++++++-- lua/core/mappings.lua | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 80b23a7..16ad154 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -196,10 +196,15 @@ M.mappings = { -- show & recover hidden terminal buffers in a telescope picker pick_term = "W", - -- spawn terminals + -- spawn a single terminal and toggle it + -- this just works like toggleterm kinda new_horizontal = "h", new_vertical = "v", - new_window = "w", + + -- spawn new terminals + spawn_horizontal = "H", + spawn_vertical = "V", + spawn_window = "w", }, } diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 9e44b7f..edb60c2 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -33,8 +33,8 @@ M.misc = function() -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ -- empty mode is same as using :map -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour - map_wrapper({"n", "x", "o"}, "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true }) - map_wrapper({"n", "x", "o"}, "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true }) + map_wrapper({ "n", "x", "o" }, "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true }) + map_wrapper({ "n", "x", "o" }, "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true }) map_wrapper("", "", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true }) map_wrapper("", "", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true }) @@ -115,7 +115,16 @@ M.misc = function() .. tostring(terminal_options.window.vsplit_width) .. ")" ) - --map("n", term_maps.new_window, "") not supported yet + + -- spawns terminals + map( + "n", + term_maps.spawn_horizontal, + ":execute 15 .. 'new +terminal' | let b:term_type = 'hori' | startinsert " + ) + map("n", term_maps.spawn_vertical, ":execute 'vnew +terminal' | let b:term_type = 'vert' | startinsert ") + map("n", term_maps.new_window, ":execute 'terminal' | let b:term_type = 'wind' | startinsert ") + -- terminal mappings end -- -- Add Packer commands because we are not loading it at startup