From 24d2ac2373598c032f37d70c46803feefd169084 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 26 Oct 2025 00:39:23 +0200 Subject: [PATCH] plugins/venv-selector: init --- plugins/by-name/venv-selector/default.nix | 40 +++++++++++ .../plugins/by-name/venv-selector/default.nix | 68 +++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 plugins/by-name/venv-selector/default.nix create mode 100644 tests/test-sources/plugins/by-name/venv-selector/default.nix diff --git a/plugins/by-name/venv-selector/default.nix b/plugins/by-name/venv-selector/default.nix new file mode 100644 index 00000000..d60cb869 --- /dev/null +++ b/plugins/by-name/venv-selector/default.nix @@ -0,0 +1,40 @@ +{ + lib, + config, + ... +}: +lib.nixvim.plugins.mkNeovimPlugin { + name = "venv-selector"; + package = "venv-selector-nvim"; + + maintainers = [ lib.maintainers.GaetanLepage ]; + + dependencies = [ + "fd" + ]; + + settingsExample = { + name = [ + "venv" + ".venv" + ]; + dap_enabled = true; + pyenv_path = lib.nixvim.nestedLiteralLua "vim.fn.expand('$HOME/.pyenv/versions')"; + }; + + extraConfig = cfg: { + warnings = lib.nixvim.mkWarnings "plugins.venv-selector" ( + lib.map + (pickerName: { + when = (cfg.settings.picker or null) == pickerName && !config.plugins.${pickerName}.enable; + message = '' + You have to enable `plugins.${pickerName}` as `settings.picker` is set to `"${pickerName}"`. + ''; + }) + [ + "telescope" + "fzf-lua" + ] + ); + }; +} diff --git a/tests/test-sources/plugins/by-name/venv-selector/default.nix b/tests/test-sources/plugins/by-name/venv-selector/default.nix new file mode 100644 index 00000000..30ce949d --- /dev/null +++ b/tests/test-sources/plugins/by-name/venv-selector/default.nix @@ -0,0 +1,68 @@ +{ lib, ... }: +{ + empty = { + plugins.venv-selector.enable = true; + }; + + example = { + plugins.venv-selector = { + enable = true; + + settings = { + name = [ + "venv" + ".venv" + ]; + dap_enabled = true; + pyenv_path = lib.nixvim.mkRaw "vim.fn.expand('$HOME/.pyenv/versions')"; + }; + }; + }; + + defaults = { + plugins.venv-selector = { + enable = true; + + settings = { + cache.file = "~/.cache/venv-selector/venvs2.json"; + hooks = [ + (lib.nixvim.mkRaw "require('venv-selector.hooks').dynamic_python_lsp_hook") + ]; + options = { + on_venv_activate_callback = null; + enable_default_searches = true; + enable_cached_venvs = true; + cached_venv_automatic_activation = true; + activate_venv_in_terminal = true; + set_environment_variables = true; + notify_user_on_venv_activation = false; + search_timeout = 5; + debug = false; + fd_binary_name = lib.nixvim.mkRaw "require('venv-selector.config').find_fd_command_name()"; + require_lsp_activation = true; + on_telescope_result_callback = null; + picker_filter_type = "substring"; + selected_venv_marker_color = "#00FF00"; + selected_venv_marker_icon = "✔"; + picker_icons = [ ]; + picker_columns = [ + "marker" + "search_icon" + "search_name" + "search_result" + ]; + picker = "auto"; + statusline_func = { + nvchad = null; + lualine = null; + }; + picker_options = { + snacks = { + layout.preset = "select"; + }; + }; + }; + }; + }; + }; +}