setup codecompanion with ollama models
This commit is contained in:
parent
939e8a45f5
commit
9b6463240c
2 changed files with 202 additions and 0 deletions
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
# Completion & AI Assistancee
|
||||
./plugins/cmp/cmp.nix
|
||||
./plugins/cmp/codecompanion.nix
|
||||
|
||||
# Editor Enhancements
|
||||
./plugins/editor/commentary.nix
|
||||
|
|
|
|||
201
config/plugins/cmp/codecompanion.nix
Normal file
201
config/plugins/cmp/codecompanion.nix
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
{...}: {
|
||||
plugins.codecompanion = {
|
||||
enable = true;
|
||||
|
||||
# Settings for the CodeCompanion plugin
|
||||
settings = {
|
||||
# Display options for the chat interface
|
||||
display = {
|
||||
chat.window = {
|
||||
layout = "vertical";
|
||||
position = "right";
|
||||
width = 0.33;
|
||||
};
|
||||
};
|
||||
|
||||
# Adapters for different backends
|
||||
adapters = {
|
||||
http = {
|
||||
"ollama:qwen2.5-coder" = {
|
||||
__raw = ''
|
||||
function()
|
||||
return require('codecompanion.adapters').extend('ollama', {
|
||||
name = "ollama:qwen2.5-coder",
|
||||
env = {
|
||||
url = "http://127.0.0.1:11434",
|
||||
},
|
||||
schema = {
|
||||
model = {
|
||||
default = 'qwen2.5-coder:7b',
|
||||
},
|
||||
num_ctx = {
|
||||
default = 32768,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
"ollama:deepseek-r1" = {
|
||||
__raw = ''
|
||||
function()
|
||||
return require('codecompanion.adapters').extend('ollama', {
|
||||
name = "ollama:deepseek-r1",
|
||||
env = {
|
||||
url = "http://127.0.0.1:11434",
|
||||
},
|
||||
schema = {
|
||||
model = {
|
||||
default = 'deepseek-r1:8b',
|
||||
},
|
||||
num_ctx = {
|
||||
default = 131072,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
"ollama:gemma3" = {
|
||||
__raw = ''
|
||||
function()
|
||||
return require('codecompanion.adapters').extend('ollama', {
|
||||
name = "ollama:gemma3",
|
||||
env = {
|
||||
url = "http://127.0.0.1:11434",
|
||||
},
|
||||
schema = {
|
||||
model = {
|
||||
default = 'gemma3:4b',
|
||||
},
|
||||
num_ctx = {
|
||||
default = 131072,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
"ollama:qwen3" = {
|
||||
__raw = ''
|
||||
function()
|
||||
return require('codecompanion.adapters').extend('ollama', {
|
||||
name = "ollama:qwen3",
|
||||
env = {
|
||||
url = "http://127.0.0.1:11434",
|
||||
},
|
||||
schema = {
|
||||
model = {
|
||||
default = 'qwen3:8b',
|
||||
},
|
||||
num_ctx = {
|
||||
default = 40960,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
"ollama:llama3" = {
|
||||
__raw = ''
|
||||
function()
|
||||
return require('codecompanion.adapters').extend('ollama', {
|
||||
name = "ollama:llama3",
|
||||
env = {
|
||||
url = "http://127.0.0.1:11434",
|
||||
},
|
||||
schema = {
|
||||
model = {
|
||||
default = 'llama3:8b',
|
||||
},
|
||||
num_ctx = {
|
||||
default = 8192,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
# Options for the HTTP protocol
|
||||
opts = {
|
||||
# Enable or disable displaying default adapters
|
||||
show_defaults = false;
|
||||
};
|
||||
};
|
||||
|
||||
# Options for the ACP protocol
|
||||
acp = {
|
||||
opts = {
|
||||
# Enable or disable displaying default adapters
|
||||
show_defaults = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Global options for CodeCompanion
|
||||
opts = {
|
||||
log_level = "TRACE";
|
||||
send_code = true;
|
||||
use_default_actions = true;
|
||||
use_default_prompts = true;
|
||||
};
|
||||
|
||||
# Strategies for different interaction modes
|
||||
strategies = {
|
||||
agent = {
|
||||
adapter = "ollama:qwen2.5-coder";
|
||||
};
|
||||
chat = {
|
||||
adapter = "ollama:qwen2.5-coder";
|
||||
};
|
||||
inline = {
|
||||
adapter = "ollama:qwen2.5-coder";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Keymaps for accessing CodeCompanion functionalities
|
||||
keymaps = [
|
||||
{
|
||||
mode = ["n" "v"];
|
||||
key = "<leader>c";
|
||||
action = "<NOP>";
|
||||
options = {
|
||||
desc = "+companion";
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
mode = ["n" "v"];
|
||||
key = "<leader>cA";
|
||||
action = "<cmd>CodeCompanionActions<cr>";
|
||||
options = {
|
||||
desc = "Open actions";
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
mode = ["n" "v"];
|
||||
key = "<leader>cc";
|
||||
action = "<cmd>CodeCompanionChat Toggle<cr>";
|
||||
options = {
|
||||
desc = "Toggle chat";
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
mode = ["v"];
|
||||
key = "<leader>ca";
|
||||
action = "<cmd>CodeCompanionChat Add<cr>";
|
||||
options = {
|
||||
desc = "Add selection to chat";
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue