From daf6cec5fe27138aa2946ca7b87167f60513a36a Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 20 Mar 2025 14:24:22 +0100 Subject: [PATCH 1/3] plugins/dap (dapHelpers): internal rename configurationOption -> configurationType --- plugins/by-name/dap-go/default.nix | 2 +- plugins/by-name/dap-python/default.nix | 2 +- plugins/by-name/dap/dapHelpers.nix | 2 +- plugins/by-name/dap/default.nix | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/by-name/dap-go/default.nix b/plugins/by-name/dap-go/default.nix index 29873c6cf5..ede950018a 100644 --- a/plugins/by-name/dap-go/default.nix +++ b/plugins/by-name/dap-go/default.nix @@ -15,7 +15,7 @@ lib.nixvim.plugins.mkNeovimPlugin { maintainers = [ lib.maintainers.khaneliman ]; settingsOptions = { - dap_configurations = lib.nixvim.mkNullOrOption (types.listOf dapHelpers.configurationOption) '' + dap_configurations = lib.nixvim.mkNullOrOption (types.listOf dapHelpers.configurationType) '' Additional dap configurations. See `:h dap-configuration` for more detail. ''; diff --git a/plugins/by-name/dap-python/default.nix b/plugins/by-name/dap-python/default.nix index 912ac02dbb..6a9e6a904e 100644 --- a/plugins/by-name/dap-python/default.nix +++ b/plugins/by-name/dap-python/default.nix @@ -35,7 +35,7 @@ lib.nixvim.plugins.mkNeovimPlugin { type = types.str; }; - customConfigurations = mkNullOrOption (types.listOf dapHelpers.configurationOption) "Custom python configurations for dap."; + customConfigurations = mkNullOrOption (types.listOf dapHelpers.configurationType) "Custom python configurations for dap."; resolvePython = defaultNullOpts.mkLuaFn null '' Function to resolve path to python to use for program or test execution. diff --git a/plugins/by-name/dap/dapHelpers.nix b/plugins/by-name/dap/dapHelpers.nix index 9bf198e24c..c36f4d3026 100644 --- a/plugins/by-name/dap/dapHelpers.nix +++ b/plugins/by-name/dap/dapHelpers.nix @@ -91,7 +91,7 @@ rec { is used. A use-case for this is starting an adapter asynchronous. ''; - configurationOption = types.submodule { + configurationType = types.submodule { freeformType = types.attrs; options = { diff --git a/plugins/by-name/dap/default.nix b/plugins/by-name/dap/default.nix index 47c78539b9..5125970597 100644 --- a/plugins/by-name/dap/default.nix +++ b/plugins/by-name/dap/default.nix @@ -28,7 +28,7 @@ lib.nixvim.plugins.mkNeovimPlugin { }; configurations = - lib.nixvim.mkNullOrOption (with types; attrsOf (listOf dapHelpers.configurationOption)) + lib.nixvim.mkNullOrOption (with types; attrsOf (listOf dapHelpers.configurationType)) '' Debugger configurations, see `:h dap-configuration` for more info. ''; From 0a5dd867fcd0989b6e359e5ccd74e92b96c9d302 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 20 Mar 2025 14:24:51 +0100 Subject: [PATCH 2/3] plugins/dap (dapHelpers): allow dapHelpers.configurationType to be rawLua --- plugins/by-name/dap/dapHelpers.nix | 44 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/plugins/by-name/dap/dapHelpers.nix b/plugins/by-name/dap/dapHelpers.nix index c36f4d3026..3a542ea39e 100644 --- a/plugins/by-name/dap/dapHelpers.nix +++ b/plugins/by-name/dap/dapHelpers.nix @@ -91,31 +91,33 @@ rec { is used. A use-case for this is starting an adapter asynchronous. ''; - configurationType = types.submodule { - freeformType = types.attrs; + configurationType = types.maybeRaw ( + types.submodule { + freeformType = types.attrs; - options = { - type = lib.mkOption { - description = "Which debug adapter to use."; - type = types.str; - }; + options = { + type = lib.mkOption { + description = "Which debug adapter to use."; + type = types.str; + }; - request = lib.mkOption { - type = types.enum [ - "attach" - "launch" - ]; - description = '' - Indicates whether the debug adapter should launch a debuggee or attach to one that is already running. - ''; - }; + request = lib.mkOption { + type = types.enum [ + "attach" + "launch" + ]; + description = '' + Indicates whether the debug adapter should launch a debuggee or attach to one that is already running. + ''; + }; - name = lib.mkOption { - type = types.str; - description = "A user readable name for the configuration."; + name = lib.mkOption { + type = types.str; + description = "A user readable name for the configuration."; + }; }; - }; - }; + } + ); mkSignOption = default: desc: { text = lib.nixvim.defaultNullOpts.mkStr default desc; From 8a88d86c81b6676902723e8fb47f367aed19ed15 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 20 Mar 2025 11:40:35 +0100 Subject: [PATCH 3/3] plugins/dap-rr: init --- plugins/by-name/dap-rr/default.nix | 64 +++++++++++++++++++ .../plugins/by-name/dap-rr/default.nix | 58 +++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 plugins/by-name/dap-rr/default.nix create mode 100644 tests/test-sources/plugins/by-name/dap-rr/default.nix diff --git a/plugins/by-name/dap-rr/default.nix b/plugins/by-name/dap-rr/default.nix new file mode 100644 index 0000000000..f145865e32 --- /dev/null +++ b/plugins/by-name/dap-rr/default.nix @@ -0,0 +1,64 @@ +{ lib, ... }: +let + inherit (lib) types; + inherit (lib.nixvim) defaultNullOpts; +in +lib.nixvim.plugins.mkNeovimPlugin { + name = "dap-rr"; + packPathName = "nvim-dap-rr"; + package = "nvim-dap-rr"; + + maintainers = [ lib.maintainers.GaetanLepage ]; + + settingsOptions = { + mappings = + defaultNullOpts.mkAttrsOf types.str + { + continue = ""; + step_over = ""; + step_out = ""; + step_into = ""; + reverse_continue = ""; + reverse_step_over = ""; + reverse_step_out = ""; + reverse_step_into = ""; + step_over_i = ""; + step_out_i = ""; + step_into_i = ""; + reverse_step_over_i = ""; + reverse_step_out_i = ""; + reverse_step_into_i = ""; + } + '' + Keyboard mappings for nvim-dap-rr. + ''; + }; + + settingsExample = { + mappings = { + continue = ""; + step_over = ""; + step_out = ""; + step_into = ""; + reverse_continue = ""; + reverse_step_over = ""; + reverse_step_out = ""; + reverse_step_into = ""; + }; + }; + + # Manually supplied to nvim-dap config module + callSetup = false; + extraConfig = cfg: { + plugins.dap = { + enable = true; + extensionConfigLua = '' + require("nvim-dap-rr").setup(${lib.nixvim.toLuaObject cfg.settings}) + ''; + configurations = { + rust = lib.mkDefault [ { __raw = "require('nvim-dap-rr').get_rust_config()"; } ]; + cpp = lib.mkDefault [ { __raw = "require('nvim-dap-rr').get_config()"; } ]; + }; + }; + }; +} diff --git a/tests/test-sources/plugins/by-name/dap-rr/default.nix b/tests/test-sources/plugins/by-name/dap-rr/default.nix new file mode 100644 index 0000000000..2cb07cfba1 --- /dev/null +++ b/tests/test-sources/plugins/by-name/dap-rr/default.nix @@ -0,0 +1,58 @@ +{ + empty = { + plugins = { + dap.enable = true; + dap-rr.enable = true; + }; + }; + + defaults = { + plugins = { + dap.enable = true; + dap-rr = { + enable = true; + + settings = { + mappings = { + continue = ""; + step_over = ""; + step_out = ""; + step_into = ""; + reverse_continue = ""; + reverse_step_over = ""; + reverse_step_out = ""; + reverse_step_into = ""; + step_over_i = ""; + step_out_i = ""; + step_into_i = ""; + reverse_step_over_i = ""; + reverse_step_out_i = ""; + reverse_step_into_i = ""; + }; + }; + }; + }; + }; + + example = { + plugins = { + dap.enable = true; + dap-rr = { + enable = true; + + settings = { + mappings = { + continue = ""; + step_over = ""; + step_out = ""; + step_into = ""; + reverse_continue = ""; + reverse_step_over = ""; + reverse_step_out = ""; + reverse_step_into = ""; + }; + }; + }; + }; + }; +}