Skip to content

codecompanion doesn't let me merge context.providers #3341

Open
@auipga

Description

@auipga

This issue is about the key

  • programs.nixvim.plugins.codecompanion.settings.context.providers

context is not explicitely defined in codecompanion/default.nix

The result I want is:

{
  programs.nixvim.plugins.codecompanion.settings.context.providers = [
    { name = "git_diff"; opts = { max_lines = 400; }; }
    { name = "lsp";      opts = { diagnostics = true; definition = true; }; }
    { name = "vectorcode"; opts = { top_k = 15; }; }
  ];
}

But I need/want to merge across multiple files which won't work the ways I tried.
I don't know whether this is a bug, just not implemented or my own misconfiguration.

  • File 1:
# codecompanion.nix
{
  programs.nixvim.plugins.codecompanion.settings = {
  
    # Try 1: just define
    context.providers = [
      { name = "git_diff"; opts = { max_lines = 400; }; }
      { name = "lsp";      opts = { diagnostics = true; definition = true; }; }
    ];
    
    # Try 2: use mkMerge
    context.providers = lib.mkMerge [
      [
        { name = "git_diff"; opts = { max_lines = 400; }; }
        { name = "lsp";      opts = { diagnostics = true; definition = true; }; }
      ]
    ];
    
    # Try 3: use ++ and mkDefault
    context.providers = [
      { name = "git_diff"; opts = { max_lines = 400; }; }
      { name = "lsp";      opts = { diagnostics = true; definition = true; }; }
    ] ++ lib.mkDefault [];
    
    # Try 4: use mkBefore here and mkAfter in the other file
    context.providers = lib.mkBefore [
      { name = "git_diff"; opts = { max_lines = 400; }; }
      { name = "lsp";      opts = { diagnostics = true; definition = true; }; }
    ];
  
  };
}
  • File 2:
# codecompanion-vectorcode.nix
{
  programs.nixvim.plugins.codecompanion.settings = {
  
    # Try 1: just define
    context.providers = [
      { name = "vectorcode"; opts = { top_k = 15; }; }
    ];
    
    # Try 2: use mkMerge
    context.providers = lib.mkMerge [
      [
        { name = "vectorcode"; opts = { top_k = 15; }; }
      ]
    ];
    
    # Try 3: use ++ and mkDefault
    context.providers = [
      { name = "vectorcode"; opts = { top_k = 15; }; }
    ] ++ lib.mkDefault [];
    
    # Try 4: use mkAfter here and mkBefore in the other file
    context.providers = lib.mkAfter [
      { name = "vectorcode"; opts = { top_k = 15; }; }
    ];
  
  };
}

(I omitted non-relevant lines)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions