dapui: lazy load

This commit is contained in:
Ching Pei Yang 2024-09-30 21:58:43 +02:00 committed by Ching Pei Yang
parent edab575b52
commit 0608e107cd
No known key found for this signature in database
GPG key ID: 062FBBCE1D0C5DD9

View file

@ -6,7 +6,7 @@
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) mapAttrs; inherit (lib.attrsets) mapAttrs;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding mkSetLuaLznBinding;
inherit (lib.nvim.dag) entryAnywhere entryAfter; inherit (lib.nvim.dag) entryAnywhere entryAfter;
cfg = config.vim.debugger.nvim-dap; cfg = config.vim.debugger.nvim-dap;
@ -49,24 +49,33 @@ in {
]; ];
}) })
(mkIf (cfg.enable && cfg.ui.enable) { (mkIf (cfg.enable && cfg.ui.enable) {
vim.startPlugins = ["nvim-dap-ui" "nvim-nio"]; vim.startPlugins = ["nvim-nio"];
vim.pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' vim.lazy.plugins = [
local dapui = require("dapui") {
dapui.setup() package = "nvim-dap-ui";
'' setupModule = "dapui";
+ optionalString cfg.ui.autoStart '' setupOpts = {};
keys = [
(mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end")
];
}
];
vim.pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (
optionalString cfg.ui.autoStart ''
dap.listeners.after.event_initialized["dapui_config"] = function() dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open() require("dapui").open()
end end
dap.listeners.before.event_terminated["dapui_config"] = function() dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close() require("dapui").close()
end end
dap.listeners.before.event_exited["dapui_config"] = function() dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close() require("dapui").close()
end end
''); ''
vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle"; );
}) })
]; ];
} }