diff options
| author | kylo252 <[email protected]> | 2022-10-17 17:29:15 +0200 | 
|---|---|---|
| committer | kylo252 <[email protected]> | 2022-10-17 17:29:15 +0200 | 
| commit | 4ef07315003f723bb8e97d5a91b2bde3773ec1b8 (patch) | |
| tree | e9889a492f76e3f9573228343aaba647dfd48136 /lua/lvim/core/terminal.lua | |
| parent | e4a5fe97abe500bbbe78fb137d57a59f558da05a (diff) | |
| parent | 6f6cbc394d2a7e64964b6067a2f42d2e6a07824e (diff) | |
Merge remote-tracking branch 'origin/rolling'
Diffstat (limited to 'lua/lvim/core/terminal.lua')
| -rw-r--r-- | lua/lvim/core/terminal.lua | 35 | 
1 files changed, 29 insertions, 6 deletions
| diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index 6f543d06..006452e1 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -3,11 +3,11 @@ local Log = require "lvim.core.log"  M.config = function()    lvim.builtin["terminal"] = { +    active = true,      on_config_done = nil,      -- size can be a number or function which is passed the current terminal      size = 20, -    -- open_mapping = [[<c-\>]], -    open_mapping = [[<c-t>]], +    open_mapping = [[<c-\>]],      hide_numbers = true, -- hide the number column in toggleterm buffers      shade_filetypes = {},      shade_terminals = true, @@ -39,8 +39,11 @@ M.config = function()      -- { exec, keymap, name}      -- lvim.builtin.terminal.execs = {{}} to overwrite      -- 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 @@ -57,7 +60,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,14 +79,14 @@ M.add_exec = function(opts)    end    vim.keymap.set({ "n", "t" }, opts.keymap, function() -    M._exec_toggle { cmd = opts.cmd, count = opts.count, direction = opts.direction } +    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 @@ -109,4 +112,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 | 
