summaryrefslogtreecommitdiff
path: root/lua/lvim/core
diff options
context:
space:
mode:
authorChristian Chiarulli <[email protected]>2022-09-30 16:21:17 +0000
committerGitHub <[email protected]>2022-09-30 12:21:17 -0400
commitc38957538ddae0c600224cdf1e8389683a63c6d3 (patch)
treee077a1bb4e9574090c06ae7b1eba4e5183c0d6fc /lua/lvim/core
parent9930fc3ae45ebd30ea491e615dd4fed3973b38ce (diff)
feat(terminal): better mappings (#3104)
Diffstat (limited to 'lua/lvim/core')
-rw-r--r--lua/lvim/core/terminal.lua33
-rw-r--r--lua/lvim/core/which-key.lua1
2 files changed, 28 insertions, 6 deletions
diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua
index 8b44ec19..57d44c9a 100644
--- a/lua/lvim/core/terminal.lua
+++ b/lua/lvim/core/terminal.lua
@@ -7,7 +7,6 @@ M.config = function()
-- size can be a number or function which is passed the current terminal
size = 20,
open_mapping = [[<c-\>]],
- -- open_mapping = [[<c-t>]],
hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {},
shade_terminals = true,
@@ -41,7 +40,9 @@ M.config = function()
-- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"}
-- TODO: pls add mappings in which key and refactor this
execs = {
- { "lazygit", "<leader>gg", "LazyGit", "float" },
+ { vim.o.shell, "<M-1>", "Horizontal Terminal", "horizontal", 10 },
+ { vim.o.shell, "<M-2>", "Vertical Terminal", "vertical", 60 },
+ { vim.o.shell, "<M-3>", "Float Terminal", "float", nil },
},
}
end
@@ -58,7 +59,7 @@ M.setup = function()
-- NOTE: unable to consistently bind id/count <= 9, see #2146
count = i + 100,
direction = exec[4] or lvim.builtin.terminal.direction,
- size = lvim.builtin.terminal.size,
+ size = exec[5] or lvim.builtin.terminal.size,
}
M.add_exec(opts)
@@ -76,15 +77,15 @@ M.add_exec = function(opts)
return
end
- vim.keymap.set({ "n" }, opts.keymap, function()
- M._exec_toggle { cmd = opts.cmd, count = opts.count, direction = opts.direction }
+ vim.keymap.set({ "n", "t" }, opts.keymap, function()
+ M._exec_toggle { cmd = opts.cmd, count = opts.count, direction = opts.direction, size = opts.size }
end, { desc = opts.label, noremap = true, silent = true })
end
M._exec_toggle = function(opts)
local Terminal = require("toggleterm.terminal").Terminal
local term = Terminal:new { cmd = opts.cmd, count = opts.count, direction = opts.direction }
- term:toggle(lvim.builtin.terminal.size, opts.direction)
+ term:toggle(opts.size, opts.direction)
end
---Toggles a log viewer according to log.viewer.layout_config
@@ -110,4 +111,24 @@ M.toggle_log_view = function(logfile)
log_view:toggle()
end
+M.lazygit_toggle = function()
+ local Terminal = require("toggleterm.terminal").Terminal
+ local lazygit = Terminal:new {
+ cmd = "lazygit",
+ hidden = true,
+ direction = "float",
+ float_opts = {
+ border = "none",
+ width = 100000,
+ height = 100000,
+ },
+ on_open = function(_)
+ vim.cmd "startinsert!"
+ end,
+ on_close = function(_) end,
+ count = 99,
+ }
+ lazygit:toggle()
+end
+
return M
diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua
index 8b4f7b8b..588ecce5 100644
--- a/lua/lvim/core/which-key.lua
+++ b/lua/lvim/core/which-key.lua
@@ -130,6 +130,7 @@ M.config = function()
-- " Debugging
g = {
name = "Git",
+ g = { "<cmd>lua require 'lvim.core.terminal'.lazygit_toggle()<cr>", "Lazygit" },
j = { "<cmd>lua require 'gitsigns'.next_hunk()<cr>", "Next Hunk" },
k = { "<cmd>lua require 'gitsigns'.prev_hunk()<cr>", "Prev Hunk" },
l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" },