perf(toggleterm): on-demand lazy load (#3811)

* perf(toggleterm): on-demand lazy load

* fix: keys

* fix: move setup, on_config_done (for terminal obj)

* fix: add some cmds

* refactor: remove redundant `lazy = true`
This commit is contained in:
opalmay 2023-02-11 19:43:38 +02:00 committed by GitHub
parent baf71343f0
commit fde46c4b16
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View file

@ -77,10 +77,7 @@ local function get_dynamic_terminal_size(direction, size)
end
end
M.setup = function()
local terminal = require "toggleterm"
terminal.setup(lvim.builtin.terminal)
M.init = function()
for i, exec in pairs(lvim.builtin.terminal.execs) do
local direction = exec[4] or lvim.builtin.terminal.direction
@ -98,7 +95,11 @@ M.setup = function()
M.add_exec(opts)
end
end
M.setup = function()
local terminal = require "toggleterm"
terminal.setup(lvim.builtin.terminal)
if lvim.builtin.terminal.on_config_done then
lvim.builtin.terminal.on_config_done(terminal)
end

View file

@ -280,11 +280,22 @@ local core_plugins = {
-- Terminal
{
"akinsho/toggleterm.nvim",
event = "VeryLazy",
branch = "main",
init = function()
require("lvim.core.terminal").init()
end,
config = function()
require("lvim.core.terminal").setup()
end,
cmd = {
"ToggleTerm",
"TermExec",
"ToggleTermToggleAll",
"ToggleTermSendCurrentLine",
"ToggleTermSendVisualLines",
"ToggleTermSendVisualSelection",
},
keys = lvim.builtin.terminal.open_mapping,
enabled = lvim.builtin.terminal.active,
},