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
This commit is contained in:
Alexandra Østermark 2025-05-18 20:31:56 +02:00
commit c4d040b0b0
No known key found for this signature in database
GPG key ID: C2B9D34D979B6063
5 changed files with 86 additions and 115 deletions

View file

@ -248,6 +248,7 @@ isMaximal: {
cmp.enable = isMaximal;
};
codecompanion-nvim.enable = false;
avante-nvim.enable = isMaximal;
};
session = {

View file

@ -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"

View file

@ -28,6 +28,7 @@
rev = pin.revision;
sha256 = pin.hash;
};
pins = self.pins;
};
inherit (docs.manual) htmlOpenTool;

View file

@ -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.
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,13 +204,10 @@ in {
};
sidebar_header = {
enabled =
mkEnableOption ""
// {
enabled = mkOption {
type = bool;
default = true;
description = ''
enable/disable the header.
'';
description = "enable/disable the header.";
};
align = mkOption {
@ -245,9 +216,8 @@ in {
description = "Position of the title.";
};
rounded =
mkEnableOption ""
// {
rounded = mkOption {
type = bool;
default = true;
description = "Enable rounded sidebar header";
};
@ -276,9 +246,8 @@ in {
description = "The border type on the edit window.";
};
start_insert =
mkEnableOption ""
// {
start_insert = mkOption {
type = bool;
default = true;
description = ''
Start insert mode when opening the edit window.
@ -287,18 +256,16 @@ in {
};
ask = {
floating =
mkEnableOption ""
// {
floating = mkOption {
type = bool;
default = false;
description = ''
Open the 'AvanteAsk' prompt in a floating window.
'';
};
start_insert =
mkEnableOption ""
// {
start_insert = mkOption {
type = bool;
default = true;
description = ''
Start insert mode when opening the ask window.
@ -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.
'';

View file

@ -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 = [
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 = {