From 0608e107cdba656c22b62d36bdd832f3957975f8 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Mon, 30 Sep 2024 21:58:43 +0200 Subject: [PATCH] dapui: lazy load --- modules/plugins/debugger/nvim-dap/config.nix | 33 +++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/modules/plugins/debugger/nvim-dap/config.nix b/modules/plugins/debugger/nvim-dap/config.nix index 072ad9a..1c80ac4 100644 --- a/modules/plugins/debugger/nvim-dap/config.nix +++ b/modules/plugins/debugger/nvim-dap/config.nix @@ -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"; + '' + ); }) ]; }