Something went wrong. Try again.
forked from nix-community/nixvim
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108{ config, lib, pkgs, ...}:let inherit (lib) optionalString types ; inherit (lib.nixvim) defaultNullOpts mkNullOrOption toLuaObject ;
dapHelpers = import ../dap/dapHelpers.nix { inherit lib; };inlib.nixvim.plugins.mkNeovimPlugin { name = "dap-python"; package = "nvim-dap-python"; description = "An extension for nvim-dap, providing default configurations for python.";
maintainers = [ lib.maintainers.khaneliman ];
extraOptions = { adapterPythonPath = lib.mkOption { default = lib.getExe (pkgs.python3.withPackages (ps: [ ps.debugpy ])); defaultText = lib.literalExpression '' lib.getExe (pkgs.python3.withPackages (ps: [ ps.debugpy ])) ''; description = '' Path to the python interpreter. Path must be absolute or in $PATH and needs to have the `debugpy` package installed. ''; type = types.str; };
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. By default the `VIRTUAL_ENV` and `CONDA_PREFIX` environment variables are used if present. '';
testRunner = defaultNullOpts.mkLuaFn' { description = "The name of test runner to use by default."; pluginDefault = lib.literalMD '' The default value is dynamic and depends on `pytest.ini` or `manage.py` markers. If neither are found, `"unittest"` is used. ''; };
testRunners = mkNullOrOption (with lib.types; attrsOf strLuaFn) '' Set to register test runners.
Built-in test runners include: `unittest`, `pytest` and `django`.
The key is the test runner name, the value a function to generate the module name to run and its arguments.
See `|dap-python.TestRunner|`. ''; };
settingsOptions = { console = defaultNullOpts.mkEnumFirstDefault [ "integratedTerminal" "internalConsole" "externalTerminal" ] "Debugpy console.";
includeConfigs = defaultNullOpts.mkBool true "Add default configurations."; };
# Manually supplied to nvim-dap config module callSetup = false; extraConfig = cfg: { 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) imports = [ ./deprecations.nix ];}