diff --git a/plugins/by-name/avante/default.nix b/plugins/by-name/avante/default.nix new file mode 100644 index 00000000..fef0f695 --- /dev/null +++ b/plugins/by-name/avante/default.nix @@ -0,0 +1,86 @@ +{ lib, ... }: +let + inherit (lib.nixvim) defaultNullOpts mkNullOrOption' toLuaObject; +in +lib.nixvim.neovim-plugin.mkNeovimPlugin { + name = "avante"; + originalName = "avante.nvim"; + package = "avante-nvim"; + + maintainers = [ lib.maintainers.GaetanLepage ]; + + settingsOptions = { + provider = defaultNullOpts.mkStr "claude" '' + The LLM provider (`"claude"`, `"openai"`, `"azure"`, ...) + ''; + + auto_suggestions_frequency = defaultNullOpts.mkStr "claude" '' + The provider for automatic suggestions. + + Since auto-suggestions are a high-frequency operation and therefore expensive, it is + recommended to specify an inexpensive provider or even a free provider: `"copilot"`. + ''; + + mappings = mkNullOrOption' { + type = with lib.types; attrsOf (either str (attrsOf str)); + example = { + diff = { + ours = "co"; + theirs = "ct"; + none = "c0"; + both = "cb"; + next = "]x"; + prev = "[x"; + }; + jump = { + next = "]]"; + prev = "[["; + }; + }; + }; + }; + + settingsExample = { + provider = "claude"; + claude = { + endpoint = "https://api.anthropic.com"; + model = "claude-3-5-sonnet-20240620"; + temperature = 0; + max_tokens = 4096; + }; + mappings = { + diff = { + ours = "co"; + theirs = "ct"; + none = "c0"; + both = "cb"; + next = "]x"; + prev = "[x"; + }; + }; + hints.enabled = true; + windows = { + wrap = true; + width = 30; + sidebar_header = { + align = "center"; + rounded = true; + }; + }; + highlights.diff = { + current = "DiffText"; + incoming = "DiffAdd"; + }; + diff = { + debug = false; + autojump = true; + list_opener = "copen"; + }; + }; + + extraConfig = _: { + plugins.avante.luaConfig.pre = '' + require('avante_lib').load() + ''; + }; +} diff --git a/tests/test-sources/plugins/by-name/avante/default.nix b/tests/test-sources/plugins/by-name/avante/default.nix new file mode 100644 index 00000000..3e8128c2 --- /dev/null +++ b/tests/test-sources/plugins/by-name/avante/default.nix @@ -0,0 +1,200 @@ +{ + empty = { + plugins.avante.enable = true; + }; + + defaults = { + plugins.avante = { + enable = true; + + settings = { + debug = false; + provider = "claude"; + auto_suggestions_provider = "claude"; + tokenizer = "tiktoken"; + system_prompt = '' + You are an excellent programming expert. + ''; + openai = { + endpoint = "https://api.openai.com/v1"; + model = "gpt-4o"; + timeout = 30000; + temperature = 0; + max_tokens = 4096; + local = false; + }; + copilot = { + endpoint = "https://api.githubcopilot.com"; + model = "gpt-4o-2024-05-13"; + proxy = null; + allow_insecure = false; + timeout = 30000; + temperature = 0; + max_tokens = 4096; + }; + azure = { + endpoint = ""; + deployment = ""; + api_version = "2024-06-01"; + timeout = 30000; + temperature = 0; + max_tokens = 4096; + local = false; + }; + claude = { + endpoint = "https://api.anthropic.com"; + model = "claude-3-5-sonnet-20240620"; + timeout = 30000; + temperature = 0; + max_tokens = 8000; + local = false; + }; + gemini = { + endpoint = "https://generativelanguage.googleapis.com/v1beta/models"; + model = "gemini-1.5-flash-latest"; + timeout = 30000; + temperature = 0; + max_tokens = 4096; + local = false; + }; + cohere = { + endpoint = "https://api.cohere.com/v1"; + model = "command-r-plus-08-2024"; + timeout = 30000; + temperature = 0; + max_tokens = 4096; + local = false; + }; + vendors = { }; + behaviour = { + auto_suggestions = false; + auto_set_highlight_group = true; + auto_set_keymaps = true; + auto_apply_diff_after_generation = false; + support_paste_from_clipboard = false; + }; + history = { + storage_path.__raw = "vim.fn.stdpath('state') .. '/avante'"; + paste = { + extension = "png"; + filename = "pasted-%Y-%m-%d-%H-%M-%S"; + }; + }; + highlights = { + diff = { + current = "DiffText"; + incoming = "DiffAdd"; + }; + }; + mappings = { + diff = { + ours = "co"; + theirs = "ct"; + all_theirs = "ca"; + both = "cb"; + cursor = "cc"; + next = "]x"; + prev = "[x"; + }; + suggestion = { + accept = ""; + next = ""; + prev = ""; + dismiss = ""; + }; + jump = { + next = "]]"; + prev = "[["; + }; + submit = { + normal = ""; + insert = ""; + }; + ask = "aa"; + edit = "ae"; + refresh = "ar"; + toggle = { + default = "at"; + debug = "ad"; + hint = "ah"; + suggestion = "as"; + }; + sidebar = { + switch_windows = ""; + reverse_switch_windows = ""; + }; + }; + windows = { + position = "right"; + wrap = true; + width = 30; + height = 30; + sidebar_header = { + align = "center"; + rounded = true; + }; + input = { + prefix = "> "; + }; + edit = { + border = "rounded"; + }; + }; + diff = { + autojump = true; + }; + hints = { + enabled = true; + }; + }; + }; + }; + + example = { + plugins.avante = { + enable = true; + + settings = { + provider = "claude"; + claude = { + endpoint = "https://api.anthropic.com"; + model = "claude-3-5-sonnet-20240620"; + temperature = 0; + max_tokens = 4096; + }; + mappings = { + diff = { + ours = "co"; + theirs = "ct"; + none = "c0"; + both = "cb"; + next = "]x"; + prev = "[x"; + }; + jump = { + next = "]]"; + prev = "[["; + }; + }; + hints.enabled = true; + windows = { + wrap = true; + width = 30; + sidebar_header = { + align = "center"; + rounded = true; + }; + }; + highlights.diff = { + current = "DiffText"; + incoming = "DiffAdd"; + }; + diff = { + debug = false; + autojump = true; + list_opener = "copen"; + }; + }; + }; + }; +}