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.modules) mkIf mkMerge;
inherit (lib.attrsets) mapAttrs;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding mkSetLuaLznBinding;
inherit (lib.nvim.dag) entryAnywhere entryAfter;
cfg = config.vim.debugger.nvim-dap;
@ -49,24 +49,33 @@ in {
];
})
(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"] (''
local dapui = require("dapui")
dapui.setup()
''
+ optionalString cfg.ui.autoStart ''
vim.lazy.plugins = [
{
package = "nvim-dap-ui";
setupModule = "dapui";
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()
dapui.open()
require("dapui").open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
require("dapui").close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
require("dapui").close()
end
'');
vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle";
''
);
})
];
}