From 5f74bfcc1163cff8fe660223dae6b435058c15dc Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 25 Nov 2025 23:16:37 -0600 Subject: [PATCH] plugins/dap-python: require dap to be explicitly enabled Instead of automatically enabling `plugins.dap`, require users to explicitly enable it. This prevents silent re-enabling of dap when a user has explicitly disabled it. --- plugins/by-name/dap-python/default.nix | 42 ++++++++++--------- .../plugins/by-name/dap-python/default.nix | 3 ++ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/plugins/by-name/dap-python/default.nix b/plugins/by-name/dap-python/default.nix index 452eab26..3a286cb7 100644 --- a/plugins/by-name/dap-python/default.nix +++ b/plugins/by-name/dap-python/default.nix @@ -1,4 +1,5 @@ { + config, lib, pkgs, ... @@ -76,26 +77,29 @@ lib.nixvim.plugins.mkNeovimPlugin { # Manually supplied to nvim-dap config module callSetup = false; extraConfig = cfg: { - plugins.dap = { - enable = true; - - extensionConfigLua = '' - require("dap-python").setup("${cfg.adapterPythonPath}", ${toLuaObject cfg.settings}) - '' - + (optionalString (cfg.testRunners != null) '' - table.insert(require("dap-python").test_runners, - ${toLuaObject (builtins.mapAttrs (_: lib.nixvim.mkRaw) cfg.testRunners)}) - '') - + (optionalString (cfg.customConfigurations != null) '' - table.insert(require("dap").configurations.python, ${toLuaObject cfg.customConfigurations}) - '') - + (optionalString (cfg.resolvePython != null) '' - require("dap-python").resolve_python = ${toLuaObject cfg.resolvePython} - '') - + (optionalString (cfg.testRunner != null) '' - require("dap-python").test_runner = ${toLuaObject cfg.testRunner}; - ''); + assertions = lib.nixvim.mkAssertions "plugins.dap-python" { + assertion = config.plugins.dap.enable; + message = '' + You have to enable `plugins.dap` to use `plugins.dap-python`. + ''; }; + + plugins.dap.extensionConfigLua = '' + require("dap-python").setup("${cfg.adapterPythonPath}", ${toLuaObject cfg.settings}) + '' + + (optionalString (cfg.testRunners != null) '' + table.insert(require("dap-python").test_runners, + ${toLuaObject (builtins.mapAttrs (_: lib.nixvim.mkRaw) cfg.testRunners)}) + '') + + (optionalString (cfg.customConfigurations != null) '' + table.insert(require("dap").configurations.python, ${toLuaObject cfg.customConfigurations}) + '') + + (optionalString (cfg.resolvePython != null) '' + require("dap-python").resolve_python = ${toLuaObject cfg.resolvePython} + '') + + (optionalString (cfg.testRunner != null) '' + require("dap-python").test_runner = ${toLuaObject cfg.testRunner}; + ''); }; # NOTE: Renames added in https://github.com/nix-community/nixvim/pull/2897 (2025-01-26) diff --git a/tests/test-sources/plugins/by-name/dap-python/default.nix b/tests/test-sources/plugins/by-name/dap-python/default.nix index b5af602a..c8b9c637 100644 --- a/tests/test-sources/plugins/by-name/dap-python/default.nix +++ b/tests/test-sources/plugins/by-name/dap-python/default.nix @@ -1,9 +1,11 @@ { empty = { + plugins.dap.enable = true; plugins.dap-python.enable = true; }; example = { + plugins.dap.enable = true; plugins.dap-python = { enable = true; @@ -34,6 +36,7 @@ }; default = { + plugins.dap.enable = true; plugins.dap-python = { enable = true;