plugins/whichpy: init

This commit is contained in:
Kasper Seweryn 2025-04-06 15:04:20 +02:00 committed by Gaétan Lepage
parent 3c600e2876
commit e537d4a6b4
2 changed files with 141 additions and 0 deletions

View file

@ -0,0 +1,56 @@
{
lib,
config,
...
}:
lib.nixvim.plugins.mkNeovimPlugin {
name = "whichpy";
packPathName = "whichpy.nvim";
package = "whichpy-nvim";
maintainers = [ lib.maintainers.wvffle ];
settingsExample = {
update_path_env = true;
locator = {
workspace.depth = 3;
uv.enable = true;
};
};
extraOptions = {
neotestIntegration = lib.mkEnableOption "neotest-integration for whichpy-nvim.";
};
extraConfig = cfg: {
plugins.neotest.adapters.python.settings = lib.mkIf cfg.neotestIntegration {
python = lib.nixvim.mkRaw ''
function()
local whichpy_python = require("whichpy.envs").current_selected()
if whichpy_python then
return whichpy_python
end
return require("neotest-python.base").get_python_command
end
'';
};
warnings = lib.nixvim.mkWarnings "plugins.whichpy" [
{
when = cfg.neotestIntegration && !config.plugins.neotest.enable;
message = ''
You have enabled the neotest integration with whichpy but `plugins.neotest` is not enabled.
'';
}
{
when =
cfg.neotestIntegration
&& config.plugins.neotest.enable
&& !config.plugins.neotest.adapters.python.enable;
message = ''
You have enabled the neotest integration with whichpy but `plugins.neotest.adapters.python` is not enabled.
'';
}
];
};
}