system/neovim/plugins/codecompanion.nix

56 lines
1.2 KiB
Nix

{ lib, config, ... }:
let
inherit (lib.nix2lua) return lambda0 pipe1 require call;
reqCodeCompanionAdapters = require "codecompanion.adapters";
mkOllamaAdapter = data:
lambda0
(return (pipe1
reqCodeCompanionAdapters
(call "extend" [ "ollama" data ])
));
adapters = {
mistral = mkOllamaAdapter {
name = "mistral";
schema = {
model.default = "mistral:7b";
num_ctx.default = 16384;
num_predict.default = -1;
};
};
codellama = mkOllamaAdapter {
name = "codellama";
schema = {
model.default = "codellama:7b";
num_ctx.default = 16384;
num_predict.default = -1;
};
};
};
in
{
# dependencies
plugin.plenary-nvim = { };
plugin.codecompanion-nvim = {
enable = true;
name = "codecompanion";
setupSettings = {
inherit adapters;
strategies = {
chat.adapter = "mistral";
inline.adapter = "codellama";
cmd.adapter = "codellama";
};
};
};
plugin.nvim-cmp.setupSettings = lib.mkIf config.plugins.nvim-cmp.enable {
sources = {
per_filetype.codecompanion = [ "codecompanion" ];
};
};
}