From 327d4919365dcd1cfb857b6c1ac7a3a44970e104 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 11 Apr 2025 17:35:33 +0200 Subject: [PATCH] plugins/parrot: init --- plugins/by-name/parrot/default.nix | 34 ++++++ .../plugins/by-name/parrot/default.nix | 107 ++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 plugins/by-name/parrot/default.nix create mode 100644 tests/test-sources/plugins/by-name/parrot/default.nix diff --git a/plugins/by-name/parrot/default.nix b/plugins/by-name/parrot/default.nix new file mode 100644 index 00000000..be2e995f --- /dev/null +++ b/plugins/by-name/parrot/default.nix @@ -0,0 +1,34 @@ +{ lib, ... }: +lib.nixvim.plugins.mkNeovimPlugin { + name = "parrot"; + packPathName = "parrot.nvim"; + package = "parrot-nvim"; + + maintainers = [ lib.maintainers.GaetanLepage ]; + + extraConfig = { + dependencies.ripgrep.enable = lib.mkDefault true; + }; + + settingsExample = lib.literalExpression '' + { + cmd_prefix = "Parrot"; + providers = { + github = { + api_key.__raw = "os.getenv 'GITHUB_TOKEN'"; + topic.model = "gpt-4o"; + }; + }; + hooks = { + Ask.__raw = ''' + function(parrot, params) + local template = "Please, answer to this question: {{command}}." + local model_obj = parrot.get_model("command") + parrot.logger.info("Asking model: " .. model_obj.name) + parrot.Prompt(params, parrot.ui.Target.popup, model_obj, "🤖 Ask ~ ", template) + end + '''; + }; + }; + ''; +} diff --git a/tests/test-sources/plugins/by-name/parrot/default.nix b/tests/test-sources/plugins/by-name/parrot/default.nix new file mode 100644 index 00000000..04b17931 --- /dev/null +++ b/tests/test-sources/plugins/by-name/parrot/default.nix @@ -0,0 +1,107 @@ +# Not including defaults are they are too big +{ + minimal = { + plugins.parrot = { + enable = true; + + settings.providers.github.__empty = null; + }; + }; + + example = { + plugins.parrot = { + enable = true; + + # https://github.com/frankroeder/parrot.nvim?tab=readme-ov-file#configuration + settings = { + providers = { + anthropic = { + api_key.__raw = "os.getenv('ANTHROPIC_API_KEY')"; + endpoint = "https://api.anthropic.com/v1/messages"; + topic_prompt = "You only respond with 3 to 4 words to summarize the past conversation."; + topic = { + model = "claude-3-haiku-20240307"; + params.max_tokens = 32; + }; + params = { + chat.max_tokens = 4096; + command.max_tokens = 4096; + }; + models = [ + "claude-3-haiku-20240307" + "claude-3-opus-20240229" + "claude-3-sonnet-20240229" + ]; + }; + }; + cmd_prefix = "Prt"; + curl_params = [ ]; + state_dir.__raw = "vim.fn.stdpath('data'):gsub('/$', '') .. '/parrot/persisted'"; + chat_dir.__raw = "vim.fn.stdpath('data'):gsub('/$', '') .. '/parrot/chats'"; + chat_user_prefix = "🗨:"; + llm_prefix = "🦜:"; + chat_confirm_delete = true; + online_model_selection = false; + chat_shortcut_respond = { + modes = [ + "n" + "i" + "v" + "x" + ]; + shortcut = ""; + }; + chat_shortcut_delete = { + modes = [ + "n" + "i" + "v" + "x" + ]; + shortcut = "d"; + }; + chat_shortcut_stop = { + modes = [ + "n" + "i" + "v" + "x" + ]; + shortcut = "s"; + }; + chat_shortcut_new = { + modes = [ + "n" + "i" + "v" + "x" + ]; + shortcut = "c"; + }; + chat_free_cursor = false; + chat_prompt_buf_type = false; + toggle_target = "vsplit"; + user_input_ui = "native"; + style_popup_border = "single"; + style_popup_margin_bottom = 8; + style_popup_margin_left = 1; + style_popup_margin_right = 2; + style_popup_margin_top = 2; + style_popup_max_width = 160; + command_prompt_prefix_template = "🤖 {{llm}} ~ "; + command_auto_select_response = true; + fzf_lua_opts = { + "--ansi" = true; + "--sort" = ""; + "--info" = "inline"; + "--layout" = "reverse"; + "--preview-window" = "nohidden:right:75%"; + }; + enable_spinner = true; + spinner_type = "star"; + show_context_hints = true; + show_thinking_window = true; + }; + }; + }; +}