Skip to content

Commit

Permalink
perf(toggleterm): on-demand lazy load (LunarVim#3811)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
opalmay committed Feb 11, 2023
1 parent baf7134 commit fde46c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lua/lvim/core/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion lua/lvim/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},

Expand Down

0 comments on commit fde46c4

Please sign in to comment.