From 72c5c7f6344b9a714c95d73242b098f9141f9a59 Mon Sep 17 00:00:00 2001 From: Farouk Brown Date: Tue, 22 Apr 2025 12:17:33 +0100 Subject: [PATCH 01/14] assistant: add avante.nvim plugin --- docs/release-notes/rl-0.8.md | 7 + .../plugins/assistant/avante/avante-nvim.nix | 359 ++++++++++++++++++ modules/plugins/assistant/avante/config.nix | 44 +++ modules/plugins/assistant/avante/default.nix | 6 + modules/plugins/assistant/default.nix | 1 + npins/sources.json | 13 + 6 files changed, 430 insertions(+) create mode 100644 modules/plugins/assistant/avante/avante-nvim.nix create mode 100644 modules/plugins/assistant/avante/config.nix create mode 100644 modules/plugins/assistant/avante/default.nix diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 5dc3ca94..6fe4982f 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -344,3 +344,10 @@ [howird](https://github.com/howird): - Change python dap adapter name from `python` to commonly expected `debugpy`. + +[aionoid](https://github.com/aionoid): + +[avante-nvim]: https://github.com/yetone/avante.nvim + +- Add [avante.nvim] plugin under `vim.assistant.avante-nvim`. +- Fix [render-markdown.nvim] file_types option type to list, to accept merging. diff --git a/modules/plugins/assistant/avante/avante-nvim.nix b/modules/plugins/assistant/avante/avante-nvim.nix new file mode 100644 index 00000000..135664c2 --- /dev/null +++ b/modules/plugins/assistant/avante/avante-nvim.nix @@ -0,0 +1,359 @@ +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption literalMD; + inherit (lib.types) int str enum nullOr attrs either; + inherit (lib.nvim.types) mkPluginSetupOption luaInline; +in { + options.vim.assistant = { + avante-nvim = { + enable = mkEnableOption "complementary neovim plugin for avante.nvim"; + setupOpts = mkPluginSetupOption "avante-nvim" { + provider = mkOption { + type = nullOr str; + default = null; + description = "The provider used in Aider mode or in the planning phase of Cursor Planning Mode."; + }; + + vendors = mkOption { + type = nullOr attrs; + default = null; + description = "Define Your Custom providers."; + example = literalMD '' + ```nix + ollama = { + __inherited_from = "openai"; + api_key_name = ""; + endpoint = "http://127.0.0.1:11434/v1"; + model = "qwen2.5u-coder:7b"; + max_tokens = 4096; + disable_tools = true; + }; + ollama_ds = { + __inherited_from = "openai"; + api_key_name = ""; + endpoint = "http://127.0.0.1:11434/v1"; + model = "deepseek-r1u:7b"; + max_tokens = 4096; + disable_tools = true; + }; + ``` + ''; + }; + + auto_suggestions_provider = mkOption { + type = str; + default = "claude"; + description = '' + Since auto-suggestions are a high-frequency operation and therefore expensive, + currently designating it as `copilot` provider is dangerous because: https://github.com/yetone/avante.nvim/issues/1048 + Of course, you can reduce the request frequency by increasing `suggestion.debounce`. + ''; + }; + + cursor_applying_provider = mkOption { + type = nullOr str; + default = null; + description = '' + The provider used in the applying phase of Cursor Planning Mode, defaults to nil, + when nil uses Config.provider as the provider for the applying phase + ''; + }; + + dual_boost = { + enabled = + mkEnableOption "" + // { + default = false; + description = '' + enable/disable dual boost. + ''; + }; + + first_provider = mkOption { + type = str; + default = "openai"; + }; + + second_provider = mkOption { + type = str; + default = "claude"; + }; + + prompt = mkOption { + type = str; + default = "Based on the two reference outputs below, generate a response that incorporates elements from both but reflects your own judgment and unique perspective. Do not provide any explanation, just give the response directly. Reference Output 1: [{{provider1_output}}], Reference Output 2: [{{provider2_output}}]"; + }; + + timeout = mkOption { + type = int; + default = 60000; + description = "Timeout in milliseconds."; + }; + }; + + behaviour = { + auto_suggestions = + mkEnableOption "" + // { + default = false; + }; + + auto_set_highlight_group = + mkEnableOption "" + // { + default = true; + }; + + auto_set_keymaps = + mkEnableOption "" + // { + default = true; + }; + + auto_apply_diff_after_generation = + mkEnableOption "" + // { + default = false; + }; + + support_paste_from_clipboard = + mkEnableOption "" + // { + default = false; + }; + + minimize_diff = + mkEnableOption "" + // { + default = true; + description = "Whether to remove unchanged lines when applying a code block."; + }; + + enable_token_counting = + mkEnableOption "" + // { + default = true; + description = "Whether to enable token counting. Default to true."; + }; + + enable_cursor_planning_mode = + mkEnableOption "" + // { + default = false; + description = "Whether to enable Cursor Planning Mode. Default to false."; + }; + + enable_claude_text_editor_tool_mode = + mkEnableOption "" + // { + default = false; + description = "Whether to enable Claude Text Editor Tool Mode."; + }; + }; + + mappings = { + diff = mkOption { + type = nullOr attrs; + default = null; + description = "Define or override the default keymaps for diff."; + }; + + suggestion = mkOption { + type = nullOr attrs; + default = null; + description = "Define or override the default keymaps for suggestion actions."; + }; + + jump = mkOption { + type = nullOr attrs; + default = null; + description = "Define or override the default keymaps for jump actions."; + }; + + submit = mkOption { + type = nullOr attrs; + default = null; + description = "Define or override the default keymaps for submit actions."; + }; + + cancel = mkOption { + type = nullOr attrs; + default = null; + description = "Define or override the default keymaps for cancel actions."; + }; + + sidebar = mkOption { + type = nullOr attrs; + default = null; + description = "Define or override the default keymaps for sidebar actions."; + }; + }; + + hints.enabled = + mkEnableOption "" + // { + default = true; + description = '' + Whether to enable hints. + ''; + }; + + windows = { + position = mkOption { + type = enum ["right" "left" "top" "bottom"]; + default = "right"; + description = "The position of the sidebar."; + }; + + wrap = + mkEnableOption "" + // { + default = true; + description = '' + similar to vim.o.wrap. + ''; + }; + + width = mkOption { + type = int; + default = 30; + description = "Default % based on available width."; + }; + + sidebar_header = { + enabled = + mkEnableOption "" + // { + default = true; + description = '' + enable/disable the header. + ''; + }; + + align = mkOption { + type = enum ["right" "center" "left"]; + default = "center"; + description = "Position of the title."; + }; + + rounded = + mkEnableOption "" + // { + default = true; + }; + }; + + input = { + prefix = mkOption { + type = str; + default = "> "; + }; + + height = mkOption { + type = int; + default = 8; + description = '' + Height of the input window in vertical layout. + ''; + }; + }; + + edit = { + border = mkOption { + type = str; + default = "rounded"; + }; + + start_insert = + mkEnableOption "" + // { + default = true; + description = '' + Start insert mode when opening the edit window. + ''; + }; + }; + + ask = { + floating = + mkEnableOption "" + // { + default = false; + description = '' + Open the 'AvanteAsk' prompt in a floating window. + ''; + }; + + start_insert = + mkEnableOption "" + // { + default = true; + description = '' + Start insert mode when opening the ask window. + ''; + }; + + border = mkOption { + type = str; + default = "rounded"; + }; + + focus_on_apply = mkOption { + type = enum ["ours" "theirs"]; + default = "ours"; + description = "which diff to focus after applying."; + }; + }; + }; + + highlights = { + diff = { + current = mkOption { + type = str; + default = "DiffText"; + }; + + incoming = mkOption { + type = str; + default = "DiffAdd"; + }; + }; + }; + + diff = { + autojump = + mkEnableOption "" + // { + default = true; + }; + + list_opener = mkOption { + type = either str luaInline; + default = "copen"; + }; + + override_timeoutlen = mkOption { + type = int; + default = 500; + description = '' + Override the 'timeoutlen' setting while hovering over a diff (see :help timeoutlen). + Helps to avoid entering operator-pending mode with diff mappings starting with `c`. + Disable by setting to -1. + ''; + }; + }; + + suggestion = { + debounce = mkOption { + type = int; + default = 600; + }; + + throttle = mkOption { + type = int; + default = 600; + }; + }; + }; + }; + }; +} diff --git a/modules/plugins/assistant/avante/config.nix b/modules/plugins/assistant/avante/config.nix new file mode 100644 index 00000000..1c975558 --- /dev/null +++ b/modules/plugins/assistant/avante/config.nix @@ -0,0 +1,44 @@ +{ + pkgs, + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + + cfg = config.vim.assistant.avante-nvim; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "plenary-nvim" + "dressing-nvim" + "nui-nvim" + ]; + + lazy.plugins = { + "avante.nvim" = with pkgs.vimPlugins; { + package = avante-nvim; + setupModule = "avante"; + inherit (cfg) setupOpts; + after = + /* + lua + */ + '' + vim.opt.laststatus = 3 + ''; + }; + }; + + treesitter.enable = true; + + autocomplete.nvim-cmp = { + sources = {"avante.nvim" = "[avante]";}; + sourcePlugins = ["avante-nvim"]; + }; + + languages.markdown.extensions.render-markdown-nvim.setupOpts.file_types = lib.mkAfter ["Avante"]; + }; + }; +} diff --git a/modules/plugins/assistant/avante/default.nix b/modules/plugins/assistant/avante/default.nix new file mode 100644 index 00000000..c8ab1a1c --- /dev/null +++ b/modules/plugins/assistant/avante/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./avante-nvim.nix + ]; +} diff --git a/modules/plugins/assistant/default.nix b/modules/plugins/assistant/default.nix index 697d54f6..ab50ea4f 100644 --- a/modules/plugins/assistant/default.nix +++ b/modules/plugins/assistant/default.nix @@ -3,5 +3,6 @@ ./chatgpt ./copilot ./codecompanion + ./avante ]; } diff --git a/npins/sources.json b/npins/sources.json index 05a8c173..cc4cf05d 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -26,6 +26,19 @@ "url": "https://github.com/goolord/alpha-nvim/archive/de72250e054e5e691b9736ee30db72c65d560771.tar.gz", "hash": "0c1jkhxamfn2md7m1r5b2wpxa26y90b98yzjwf68m3fymalvkn5h" }, + "avante-nvim": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "yetone", + "repo": "avante.nvim" + }, + "branch": "main", + "submodules": false, + "revision": "eb1cd44731783024621beafe4e46204cbc9a4320", + "url": "https://github.com/yetone/avante.nvim/archive/eb1cd44731783024621beafe4e46204cbc9a4320.tar.gz", + "hash": "1hdb1b74mxq6j10fv0zh6fniwpijwbxjxc59k7xzkqj6q20lad07" + }, "base16": { "type": "Git", "repository": { From 8cde1f7b93226ec404acc40227d5a752d2956238 Mon Sep 17 00:00:00 2001 From: Farouk Brown Date: Tue, 22 Apr 2025 12:20:10 +0100 Subject: [PATCH 02/14] fix:set render-markdown.nvim file_types to list --- modules/plugins/languages/markdown.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 62081549..0dfad07c 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -9,7 +9,7 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.options) mkEnableOption mkOption; inherit (lib.lists) isList; - inherit (lib.types) bool enum either package listOf str; + inherit (lib.types) bool enum either package listOf str nullOr; inherit (lib.nvim.lua) expToLua toLuaObject; inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption; inherit (lib.nvim.dag) entryAnywhere; @@ -117,7 +117,12 @@ in { ''; }; - setupOpts = mkPluginSetupOption "render-markdown" {}; + setupOpts = mkPluginSetupOption "render-markdown" { + file_types = lib.mkOption { + type = listOf (nullOr str); + default = []; + }; + }; }; }; From 7092ff5b7b7b6e8fb2c2d8c2b47f6997a9e69d3f Mon Sep 17 00:00:00 2001 From: Farouk Brown Date: Tue, 22 Apr 2025 14:09:46 +0100 Subject: [PATCH 03/14] docs: add missing descriptions --- .../plugins/assistant/avante/avante-nvim.nix | 44 ++++++++----------- modules/plugins/languages/markdown.nix | 1 + 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/modules/plugins/assistant/avante/avante-nvim.nix b/modules/plugins/assistant/avante/avante-nvim.nix index 135664c2..e616d421 100644 --- a/modules/plugins/assistant/avante/avante-nvim.nix +++ b/modules/plugins/assistant/avante/avante-nvim.nix @@ -1,7 +1,7 @@ {lib, ...}: let inherit (lib.options) mkOption mkEnableOption literalMD; - inherit (lib.types) int str enum nullOr attrs either; - inherit (lib.nvim.types) mkPluginSetupOption luaInline; + inherit (lib.types) int str enum nullOr attrs; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.assistant = { avante-nvim = { @@ -63,24 +63,25 @@ in { mkEnableOption "" // { default = false; - description = '' - enable/disable dual boost. - ''; + description = "Whether to enable dual_boost mode."; }; first_provider = mkOption { type = str; default = "openai"; + description = "The first provider to generate response."; }; second_provider = mkOption { type = str; default = "claude"; + description = "The second provider to generate response."; }; prompt = mkOption { type = str; default = "Based on the two reference outputs below, generate a response that incorporates elements from both but reflects your own judgment and unique perspective. Do not provide any explanation, just give the response directly. Reference Output 1: [{{provider1_output}}], Reference Output 2: [{{provider2_output}}]"; + description = "The prompt to generate response based on the two reference outputs."; }; timeout = mkOption { @@ -95,30 +96,35 @@ in { mkEnableOption "" // { default = false; + description = "Whether to enable auto suggestions."; }; auto_set_highlight_group = mkEnableOption "" // { default = true; + description = "Whether to automatically set the highlight group for the current line."; }; auto_set_keymaps = mkEnableOption "" // { default = true; + description = "Whether to automatically set the keymap for the current line."; }; auto_apply_diff_after_generation = mkEnableOption "" // { default = false; + description = "Whether to automatically apply diff after LLM response."; }; support_paste_from_clipboard = mkEnableOption "" // { default = false; + description = "Whether to support pasting image from clipboard. This will be determined automatically based whether img-clip is available or not."; }; minimize_diff = @@ -239,6 +245,7 @@ in { mkEnableOption "" // { default = true; + description = "Enable rounded sidebar header"; }; }; @@ -246,6 +253,7 @@ in { prefix = mkOption { type = str; default = "> "; + description = "The prefix used on the user input."; }; height = mkOption { @@ -261,6 +269,7 @@ in { border = mkOption { type = str; default = "rounded"; + description = "The border type on the edit window."; }; start_insert = @@ -295,26 +304,13 @@ in { border = mkOption { type = str; default = "rounded"; + description = "The border type on the ask window."; }; focus_on_apply = mkOption { type = enum ["ours" "theirs"]; default = "ours"; - description = "which diff to focus after applying."; - }; - }; - }; - - highlights = { - diff = { - current = mkOption { - type = str; - default = "DiffText"; - }; - - incoming = mkOption { - type = str; - default = "DiffAdd"; + description = "Which diff to focus after applying."; }; }; }; @@ -324,13 +320,9 @@ in { mkEnableOption "" // { default = true; + description = "Automatically jumps to the next change."; }; - list_opener = mkOption { - type = either str luaInline; - default = "copen"; - }; - override_timeoutlen = mkOption { type = int; default = 500; @@ -346,11 +338,13 @@ in { debounce = mkOption { type = int; default = 600; + description = "Suggestion debounce in milliseconds."; }; throttle = mkOption { type = int; default = 600; + description = "Suggestion throttle in milliseconds."; }; }; }; diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 0dfad07c..008192e3 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -121,6 +121,7 @@ in { file_types = lib.mkOption { type = listOf (nullOr str); default = []; + description = "List of buffer filetypes to enable this plugin in. This will cause the plugin to attach to new buffers who have any of these filetypes."; }; }; }; From e21904d50d53f0da8242b2d0699e1c5938649c07 Mon Sep 17 00:00:00 2001 From: Farouk Brown Date: Tue, 22 Apr 2025 15:33:07 +0100 Subject: [PATCH 04/14] pr: revert markdown changes --- docs/release-notes/rl-0.8.md | 1 - modules/plugins/languages/markdown.nix | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 6fe4982f..0e5103c1 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -350,4 +350,3 @@ [avante-nvim]: https://github.com/yetone/avante.nvim - Add [avante.nvim] plugin under `vim.assistant.avante-nvim`. -- Fix [render-markdown.nvim] file_types option type to list, to accept merging. diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 008192e3..62081549 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -9,7 +9,7 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.options) mkEnableOption mkOption; inherit (lib.lists) isList; - inherit (lib.types) bool enum either package listOf str nullOr; + inherit (lib.types) bool enum either package listOf str; inherit (lib.nvim.lua) expToLua toLuaObject; inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption; inherit (lib.nvim.dag) entryAnywhere; @@ -117,13 +117,7 @@ in { ''; }; - setupOpts = mkPluginSetupOption "render-markdown" { - file_types = lib.mkOption { - type = listOf (nullOr str); - default = []; - description = "List of buffer filetypes to enable this plugin in. This will cause the plugin to attach to new buffers who have any of these filetypes."; - }; - }; + setupOpts = mkPluginSetupOption "render-markdown" {}; }; }; From f0fe0b0f62e44a77c75a7c316d7a9e8d545b1b51 Mon Sep 17 00:00:00 2001 From: Farouk Brown Date: Thu, 24 Apr 2025 22:14:02 +0100 Subject: [PATCH 05/14] doc: format descriptions --- modules/plugins/assistant/avante/avante-nvim.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/plugins/assistant/avante/avante-nvim.nix b/modules/plugins/assistant/avante/avante-nvim.nix index e616d421..3e101865 100644 --- a/modules/plugins/assistant/avante/avante-nvim.nix +++ b/modules/plugins/assistant/avante/avante-nvim.nix @@ -44,7 +44,8 @@ in { default = "claude"; description = '' Since auto-suggestions are a high-frequency operation and therefore expensive, - currently designating it as `copilot` provider is dangerous because: https://github.com/yetone/avante.nvim/issues/1048 + currently designating it as `copilot` provider is dangerous because: + https://github.com/yetone/avante.nvim/issues/1048 Of course, you can reduce the request frequency by increasing `suggestion.debounce`. ''; }; @@ -124,7 +125,10 @@ in { mkEnableOption "" // { default = false; - description = "Whether to support pasting image from clipboard. This will be determined automatically based whether img-clip is available or not."; + description = '' + Whether to support pasting image from clipboard. + This will be determined automatically based whether img-clip is available or not. + ''; }; minimize_diff = From 75fa8e22b645c68c611e7512578fe551bf773547 Mon Sep 17 00:00:00 2001 From: Farouk Brown Date: Thu, 24 Apr 2025 22:31:14 +0100 Subject: [PATCH 06/14] fix: lazy load avante.nvim plugin --- modules/plugins/assistant/avante/config.nix | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/modules/plugins/assistant/avante/config.nix b/modules/plugins/assistant/avante/config.nix index 1c975558..369ff24e 100644 --- a/modules/plugins/assistant/avante/config.nix +++ b/modules/plugins/assistant/avante/config.nix @@ -21,23 +21,12 @@ in { package = avante-nvim; setupModule = "avante"; inherit (cfg) setupOpts; - after = - /* - lua - */ - '' - vim.opt.laststatus = 3 - ''; + event = ["DeferredUIEnter"]; }; }; treesitter.enable = true; - autocomplete.nvim-cmp = { - sources = {"avante.nvim" = "[avante]";}; - sourcePlugins = ["avante-nvim"]; - }; - languages.markdown.extensions.render-markdown-nvim.setupOpts.file_types = lib.mkAfter ["Avante"]; }; }; From f8779d1968b74292146c7b15e3b8f066b492163f Mon Sep 17 00:00:00 2001 From: Farouk Brown Date: Thu, 24 Apr 2025 22:31:45 +0100 Subject: [PATCH 07/14] chore:set npins to follow nixpkgs avante version --- npins/sources.json | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/npins/sources.json b/npins/sources.json index 0fe81d49..d7e15028 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -27,17 +27,20 @@ "hash": "0c1jkhxamfn2md7m1r5b2wpxa26y90b98yzjwf68m3fymalvkn5h" }, "avante-nvim": { - "type": "Git", + "type": "GitRelease", "repository": { "type": "GitHub", "owner": "yetone", "repo": "avante.nvim" }, - "branch": "main", + "pre_releases": false, + "version_upper_bound": null, + "release_prefix": null, "submodules": false, - "revision": "eb1cd44731783024621beafe4e46204cbc9a4320", - "url": "https://github.com/yetone/avante.nvim/archive/eb1cd44731783024621beafe4e46204cbc9a4320.tar.gz", - "hash": "1hdb1b74mxq6j10fv0zh6fniwpijwbxjxc59k7xzkqj6q20lad07" + "version": "v0.0.23", + "revision": "868c13657442b799a5c161940602f99623a08197", + "url": "https://api.github.com/repos/yetone/avante.nvim/tarball/v0.0.23", + "hash": "11h0fch0whr2mh23940h3k7l6grnp5bqv2nyxywkg1zvj680vpji" }, "base16": { "type": "Git", From 64bee7e7292785c514e2889edb72d7c4c8da395b Mon Sep 17 00:00:00 2001 From: Farouk Brown Date: Sat, 26 Apr 2025 19:45:58 +0100 Subject: [PATCH 08/14] fix: set avante-nvim to build from source --- flake/legacyPackages.nix | 11 +++ flake/legacyPackages/avante-nvim.nix | 81 +++++++++++++++++++++ modules/plugins/assistant/avante/config.nix | 5 +- modules/wrapper/build/config.nix | 2 +- npins/sources.json | 13 ++-- 5 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 flake/legacyPackages/avante-nvim.nix diff --git a/flake/legacyPackages.nix b/flake/legacyPackages.nix index 33aee0e3..0fbc269c 100644 --- a/flake/legacyPackages.nix +++ b/flake/legacyPackages.nix @@ -28,6 +28,17 @@ sha256 = pin.hash; }; }; + avante-nvim = let + pin = self.pins.avante-nvim; + in + final.callPackage ./legacyPackages/avante-nvim.nix { + version = pin.branch; + src = prev.fetchFromGitHub { + inherit (pin.repository) owner repo; + rev = pin.revision; + sha256 = pin.hash; + }; + }; }) ]; }; diff --git a/flake/legacyPackages/avante-nvim.nix b/flake/legacyPackages/avante-nvim.nix new file mode 100644 index 00000000..d54325d4 --- /dev/null +++ b/flake/legacyPackages/avante-nvim.nix @@ -0,0 +1,81 @@ +{ + nix-update-script, + openssl, + pkg-config, + rustPlatform, + stdenv, + vimPlugins, + vimUtils, + makeWrapper, + pkgs, + version, + src, +}: let + inherit version src; + avante-nvim-lib = rustPlatform.buildRustPackage { + pname = "avante-nvim-lib"; + inherit version src; + + useFetchCargoVendor = true; + cargoHash = "sha256-pmnMoNdaIR0i+4kwW3cf01vDQo39QakTCEG9AXA86ck="; + + nativeBuildInputs = [ + pkg-config + makeWrapper + pkgs.perl + ]; + + buildInputs = [ + openssl + ]; + + buildFeatures = ["luajit"]; + + checkFlags = [ + # Disabled because they access the network. + "--skip=test_hf" + "--skip=test_public_url" + "--skip=test_roundtrip" + "--skip=test_fetch_md" + ]; + }; +in + vimUtils.buildVimPlugin { + pname = "avante-nvim"; + inherit version src; + + dependencies = with vimPlugins; [ + dressing-nvim + img-clip-nvim + nui-nvim + nvim-treesitter + plenary-nvim + ]; + + postInstall = let + ext = stdenv.hostPlatform.extensions.sharedLibrary; + in '' + mkdir -p $out/build + ln -s ${avante-nvim-lib}/lib/libavante_repo_map${ext} $out/build/avante_repo_map${ext} + ln -s ${avante-nvim-lib}/lib/libavante_templates${ext} $out/build/avante_templates${ext} + ln -s ${avante-nvim-lib}/lib/libavante_tokenizers${ext} $out/build/avante_tokenizers${ext} + ln -s ${avante-nvim-lib}/lib/libavante_html2md${ext} $out/build/avante_html2md${ext} + ''; + + passthru = { + updateScript = nix-update-script { + attrPath = "vimPlugins.avante-nvim.avante-nvim-lib"; + }; + + # needed for the update script + inherit avante-nvim-lib; + }; + + nvimSkipModules = [ + # Requires setup with corresponding provider + "avante.providers.azure" + "avante.providers.copilot" + "avante.providers.vertex_claude" + "avante.providers.ollama" + ]; + } diff --git a/modules/plugins/assistant/avante/config.nix b/modules/plugins/assistant/avante/config.nix index 369ff24e..bb97780f 100644 --- a/modules/plugins/assistant/avante/config.nix +++ b/modules/plugins/assistant/avante/config.nix @@ -1,5 +1,4 @@ { - pkgs, config, lib, ... @@ -17,8 +16,8 @@ in { ]; lazy.plugins = { - "avante.nvim" = with pkgs.vimPlugins; { - package = avante-nvim; + avante-nvim = { + package = "avante-nvim"; setupModule = "avante"; inherit (cfg) setupOpts; event = ["DeferredUIEnter"]; diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index 3b147571..4d331a67 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -51,7 +51,7 @@ doCheck = false; }; - inherit (inputs.self.legacyPackages.${pkgs.stdenv.system}) blink-cmp; + inherit (inputs.self.legacyPackages.${pkgs.stdenv.system}) blink-cmp avante-nvim; }; buildConfigPlugins = plugins: diff --git a/npins/sources.json b/npins/sources.json index d7e15028..a55ed2d1 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -27,20 +27,17 @@ "hash": "0c1jkhxamfn2md7m1r5b2wpxa26y90b98yzjwf68m3fymalvkn5h" }, "avante-nvim": { - "type": "GitRelease", + "type": "Git", "repository": { "type": "GitHub", "owner": "yetone", "repo": "avante.nvim" }, - "pre_releases": false, - "version_upper_bound": null, - "release_prefix": null, + "branch": "main", "submodules": false, - "version": "v0.0.23", - "revision": "868c13657442b799a5c161940602f99623a08197", - "url": "https://api.github.com/repos/yetone/avante.nvim/tarball/v0.0.23", - "hash": "11h0fch0whr2mh23940h3k7l6grnp5bqv2nyxywkg1zvj680vpji" + "revision": "f9aa75459d403d9e963ef2647c9791e0dfc9e5f9", + "url": "https://github.com/yetone/avante.nvim/archive/f9aa75459d403d9e963ef2647c9791e0dfc9e5f9.tar.gz", + "hash": "1qgdxapmw24zkx3d4cwv6f459p2a6dw7pvx7sa3650px2n75bb31" }, "base16": { "type": "Git", From c4d040b0b03dc97a66e6bc90b22b898b6d4ef26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20=C3=98stermark?= Date: Sun, 18 May 2025 20:31:56 +0200 Subject: [PATCH 09/14] assistant/avante.nvim apply suggested changes Change the options to use mkOption when applicable and apply changes to descriptions Change the building of the vimPlugin to use npin dependencies instead of dependencies from nixpkgs --- configuration.nix | 1 + flake/avante-nvim/default.nix | 38 ++--- flake/packages.nix | 1 + .../plugins/assistant/avante/avante-nvim.nix | 142 +++++++----------- modules/plugins/assistant/avante/config.nix | 19 ++- 5 files changed, 86 insertions(+), 115 deletions(-) diff --git a/configuration.nix b/configuration.nix index dee5001f..2995fee8 100644 --- a/configuration.nix +++ b/configuration.nix @@ -248,6 +248,7 @@ isMaximal: { cmp.enable = isMaximal; }; codecompanion-nvim.enable = false; + avante-nvim.enable = isMaximal; }; session = { diff --git a/flake/avante-nvim/default.nix b/flake/avante-nvim/default.nix index 61a28fac..513a3117 100644 --- a/flake/avante-nvim/default.nix +++ b/flake/avante-nvim/default.nix @@ -10,6 +10,7 @@ pkgs, version, src, + pins, }: let inherit version src; avante-nvim-lib = rustPlatform.buildRustPackage { @@ -44,20 +45,20 @@ in pname = "avante-nvim"; inherit version src; - dependencies = with vimPlugins; [ - nvim-treesitter - dressing-nvim - plenary-nvim - nui-nvim - - # optional, not sure how we best deal with adding these as options for the user to set - mini-pick - telescope-nvim - nvim-cmp - fzf-lua - nvim-web-devicons - img-clip-nvim - ]; + dependencies = + [vimPlugins.nvim-treesitter] + ++ (builtins.map (name: let + pin = pins.${name}; + in + pkgs.fetchFromGitHub { + inherit (pin.repository) owner repo; + rev = pin.revision; + sha256 = pin.hash; + }) [ + "dressing-nvim" + "plenary-nvim" + "nui-nvim" + ]); postInstall = let ext = stdenv.hostPlatform.extensions.sharedLibrary; @@ -69,15 +70,6 @@ in ln -s ${avante-nvim-lib}/lib/libavante_html2md${ext} $out/build/avante_html2md${ext} ''; - passthru = { - updateScript = nix-update-script { - attrPath = "vimPlugins.avante-nvim.avante-nvim-lib"; - }; - - # needed for the update script - inherit avante-nvim-lib; - }; - nvimSkipModules = [ # Requires setup with corresponding provider "avante.providers.azure" diff --git a/flake/packages.nix b/flake/packages.nix index 1e9ae941..5161b34f 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -28,6 +28,7 @@ rev = pin.revision; sha256 = pin.hash; }; + pins = self.pins; }; inherit (docs.manual) htmlOpenTool; diff --git a/modules/plugins/assistant/avante/avante-nvim.nix b/modules/plugins/assistant/avante/avante-nvim.nix index 3e101865..7d52fab8 100644 --- a/modules/plugins/assistant/avante/avante-nvim.nix +++ b/modules/plugins/assistant/avante/avante-nvim.nix @@ -1,11 +1,11 @@ {lib, ...}: let inherit (lib.options) mkOption mkEnableOption literalMD; - inherit (lib.types) int str enum nullOr attrs; + inherit (lib.types) int str enum nullOr attrs bool; inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.assistant = { avante-nvim = { - enable = mkEnableOption "complementary neovim plugin for avante.nvim"; + enable = mkEnableOption "complementary Neovim plugin for avante.nvim"; setupOpts = mkPluginSetupOption "avante-nvim" { provider = mkOption { type = nullOr str; @@ -54,18 +54,13 @@ in { type = nullOr str; default = null; description = '' - The provider used in the applying phase of Cursor Planning Mode, defaults to nil, - when nil uses Config.provider as the provider for the applying phase + The provider used in the applying phase of Cursor Planning Mode, defaults to `nil`, + Config.provider will be used as the provider for the applying phase when `nil`. ''; }; dual_boost = { - enabled = - mkEnableOption "" - // { - default = false; - description = "Whether to enable dual_boost mode."; - }; + enabled = mkEnableOption "dual_boost mode."; first_provider = mkOption { type = str; @@ -81,7 +76,11 @@ in { prompt = mkOption { type = str; - default = "Based on the two reference outputs below, generate a response that incorporates elements from both but reflects your own judgment and unique perspective. Do not provide any explanation, just give the response directly. Reference Output 1: [{{provider1_output}}], Reference Output 2: [{{provider2_output}}]"; + default = '' + Based on the two reference outputs below, generate a response that incorporates + elements from both but reflects your own judgment and unique perspective. + Do not provide any explanation, just give the response directly. Reference Output 1: + [{{provider1_output}}], Reference Output 2: [{{provider2_output}}''; description = "The prompt to generate response based on the two reference outputs."; }; @@ -94,70 +93,45 @@ in { behaviour = { auto_suggestions = - mkEnableOption "" - // { - default = false; - description = "Whether to enable auto suggestions."; - }; + mkEnableOption "auto suggestions."; auto_set_highlight_group = - mkEnableOption "" + mkEnableOption "automatically set the highlight group for the current line." // { default = true; - description = "Whether to automatically set the highlight group for the current line."; }; auto_set_keymaps = - mkEnableOption "" + mkEnableOption "automatically set the keymap for the current line." // { default = true; - description = "Whether to automatically set the keymap for the current line."; }; auto_apply_diff_after_generation = - mkEnableOption "" - // { - default = false; - description = "Whether to automatically apply diff after LLM response."; - }; + mkEnableOption "automatically apply diff after LLM response."; - support_paste_from_clipboard = - mkEnableOption "" - // { - default = false; - description = '' - Whether to support pasting image from clipboard. - This will be determined automatically based whether img-clip is available or not. - ''; - }; + support_paste_from_clipboard = mkEnableOption '' + pasting image from clipboard. + This will be determined automatically based whether img-clip is available or not. + ''; minimize_diff = - mkEnableOption "" + mkEnableOption "remove unchanged lines when applying a code block." // { default = true; - description = "Whether to remove unchanged lines when applying a code block."; }; enable_token_counting = - mkEnableOption "" + mkEnableOption "token counting." // { default = true; - description = "Whether to enable token counting. Default to true."; }; enable_cursor_planning_mode = - mkEnableOption "" - // { - default = false; - description = "Whether to enable Cursor Planning Mode. Default to false."; - }; + mkEnableOption "Cursor Planning Mode."; enable_claude_text_editor_tool_mode = - mkEnableOption "" - // { - default = false; - description = "Whether to enable Claude Text Editor Tool Mode."; - }; + mkEnableOption "Claude Text Editor Tool Mode."; }; mappings = { @@ -230,14 +204,11 @@ in { }; sidebar_header = { - enabled = - mkEnableOption "" - // { - default = true; - description = '' - enable/disable the header. - ''; - }; + enabled = mkOption { + type = bool; + default = true; + description = "enable/disable the header."; + }; align = mkOption { type = enum ["right" "center" "left"]; @@ -245,12 +216,11 @@ in { description = "Position of the title."; }; - rounded = - mkEnableOption "" - // { - default = true; - description = "Enable rounded sidebar header"; - }; + rounded = mkOption { + type = bool; + default = true; + description = "Enable rounded sidebar header"; + }; }; input = { @@ -276,34 +246,31 @@ in { description = "The border type on the edit window."; }; - start_insert = - mkEnableOption "" - // { - default = true; - description = '' - Start insert mode when opening the edit window. - ''; - }; + start_insert = mkOption { + type = bool; + default = true; + description = '' + Start insert mode when opening the edit window. + ''; + }; }; ask = { - floating = - mkEnableOption "" - // { - default = false; - description = '' - Open the 'AvanteAsk' prompt in a floating window. - ''; - }; + floating = mkOption { + type = bool; + default = false; + description = '' + Open the 'AvanteAsk' prompt in a floating window. + ''; + }; - start_insert = - mkEnableOption "" - // { - default = true; - description = '' - Start insert mode when opening the ask window. - ''; - }; + start_insert = mkOption { + type = bool; + default = true; + description = '' + Start insert mode when opening the ask window. + ''; + }; border = mkOption { type = str; @@ -330,8 +297,9 @@ in { override_timeoutlen = mkOption { type = int; default = 500; + example = -1; description = '' - Override the 'timeoutlen' setting while hovering over a diff (see :help timeoutlen). + Override the 'timeoutlen' setting while hovering over a diff (see {command}`:help timeoutlen`). Helps to avoid entering operator-pending mode with diff mappings starting with `c`. Disable by setting to -1. ''; diff --git a/modules/plugins/assistant/avante/config.nix b/modules/plugins/assistant/avante/config.nix index bb97780f..e140de89 100644 --- a/modules/plugins/assistant/avante/config.nix +++ b/modules/plugins/assistant/avante/config.nix @@ -4,16 +4,25 @@ ... }: let inherit (lib.modules) mkIf; + inherit (lib.lists) optionals; cfg = config.vim.assistant.avante-nvim; in { config = mkIf cfg.enable { vim = { - startPlugins = [ - "plenary-nvim" - "dressing-nvim" - "nui-nvim" - ]; + startPlugins = + [ + "nvim-treesitter" + "plenary-nvim" + "dressing-nvim" + "nui-nvim" + ] + ++ (optionals config.vim.mini.pick.enable ["mini-pick"]) + ++ (optionals config.vim.telescope.enable ["telescope"]) + ++ (optionals config.vim.autocomplete.nvim-cmp.enable ["nvim-cmp"]) + ++ (optionals config.vim.fzf-lua.enable ["fzf-lua"]) + ++ (optionals config.vim.visuals.nvim-web-devicons.enable ["nvim-web-devicons"]) + ++ (optionals config.vim.utility.images.img-clip.enable ["img-clip"]); lazy.plugins = { avante-nvim = { From 988f034236063f4f35d557eb5cba61e23743f18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20=C3=98stermark?= Date: Tue, 3 Jun 2025 15:20:28 +0200 Subject: [PATCH 10/14] delete build deps --- flake/avante-nvim/default.nix | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/flake/avante-nvim/default.nix b/flake/avante-nvim/default.nix index 513a3117..c048c4f8 100644 --- a/flake/avante-nvim/default.nix +++ b/flake/avante-nvim/default.nix @@ -45,21 +45,6 @@ in pname = "avante-nvim"; inherit version src; - dependencies = - [vimPlugins.nvim-treesitter] - ++ (builtins.map (name: let - pin = pins.${name}; - in - pkgs.fetchFromGitHub { - inherit (pin.repository) owner repo; - rev = pin.revision; - sha256 = pin.hash; - }) [ - "dressing-nvim" - "plenary-nvim" - "nui-nvim" - ]); - postInstall = let ext = stdenv.hostPlatform.extensions.sharedLibrary; in '' From 48d5fbfa32f3675fa6d8175ff109ed546645809c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20=C3=98stermark?= Date: Tue, 3 Jun 2025 21:13:49 +0200 Subject: [PATCH 11/14] fix spelling mistake --- modules/wrapper/rc/options.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 02729401..028d903e 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -11,7 +11,7 @@ in { description = '' [official documentation]: https://neovim.io/doc/user/lua.html#vim.loader.enable() - Whethere to enable the experimental Lua module loader to speed up the start + Whether to enable the experimental Lua module loader to speed up the start up process. If `true`, this will enable the experimental Lua module loader which: From 144ab18dbd978a448da42508a9fd8088d4f0211c Mon Sep 17 00:00:00 2001 From: Callum Date: Sun, 1 Jun 2025 11:12:02 +0100 Subject: [PATCH 12/14] Fix OneDark transparancy issue --- modules/plugins/theme/supported-themes.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/plugins/theme/supported-themes.nix b/modules/plugins/theme/supported-themes.nix index 9c5e380c..9c1bf03a 100644 --- a/modules/plugins/theme/supported-themes.nix +++ b/modules/plugins/theme/supported-themes.nix @@ -21,9 +21,14 @@ in { ''; }; onedark = { - setup = {style ? "dark", ...}: '' + setup = { + style ? "dark", + transparent, + ... + }: '' -- OneDark theme require('onedark').setup { + transparent = ${boolToString transparent}, style = "${style}" } require('onedark').load() From 412d786325d38103918ad973f2af22369c7fb257 Mon Sep 17 00:00:00 2001 From: Callum Date: Tue, 3 Jun 2025 12:02:53 +0100 Subject: [PATCH 13/14] Document onedark change in release notes. --- docs/release-notes/rl-0.8.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index eb9e1f74..7ecb1085 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -418,3 +418,8 @@ - Add Clojure support under `vim.languages.clojure` using [clojure-lsp] - Add code evaluation environment [conjure] under `vim.repl.conjure` + +[CallumGilly](https://github.com/CallumGilly): + +- Add missing `transparent` option for existing + [onedark.nvim](https://github.com/navarasu/onedark.nvim) theme. From f04ad1fff5428fbf989003cdc7c1262d9951ff9d Mon Sep 17 00:00:00 2001 From: Martin Treml Date: Tue, 3 Jun 2025 23:31:58 +0200 Subject: [PATCH 14/14] fix, Add dependencies needed for building Avante Fixes #933 --- flake/avante-nvim/default.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/flake/avante-nvim/default.nix b/flake/avante-nvim/default.nix index c048c4f8..513a3117 100644 --- a/flake/avante-nvim/default.nix +++ b/flake/avante-nvim/default.nix @@ -45,6 +45,21 @@ in pname = "avante-nvim"; inherit version src; + dependencies = + [vimPlugins.nvim-treesitter] + ++ (builtins.map (name: let + pin = pins.${name}; + in + pkgs.fetchFromGitHub { + inherit (pin.repository) owner repo; + rev = pin.revision; + sha256 = pin.hash; + }) [ + "dressing-nvim" + "plenary-nvim" + "nui-nvim" + ]); + postInstall = let ext = stdenv.hostPlatform.extensions.sharedLibrary; in ''