opencode: add module
Seamlessly integrate the opencode AI assistant with Neovim — convenient and editor-aware research, reviews, and requests.
This commit is contained in:
parent
f68f9d145a
commit
e0f1e4ae4b
2 changed files with 131 additions and 0 deletions
36
plugins/by-name/opencode/default.nix
Normal file
36
plugins/by-name/opencode/default.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{ lib, ... }:
|
||||
lib.nixvim.plugins.mkNeovimPlugin {
|
||||
name = "opencode";
|
||||
packPathName = "opencode.nvim";
|
||||
package = "opencode-nvim";
|
||||
|
||||
maintainers = [ lib.maintainers.khaneliman ];
|
||||
|
||||
description = ''
|
||||
OpenCode.nvim provides seamless integration with Claude Code for AI-assisted development.
|
||||
|
||||
> [!NOTE]
|
||||
> Recommended: `snacks.enable` with `settings.input.enabled = true` for better prompt input
|
||||
> Required: `snacks.enable` to use opencode.nvim's embedded terminal
|
||||
|
||||
> [!TIP]
|
||||
> Set `opts.autoread = true` if using the `auto_reload` option.
|
||||
'';
|
||||
|
||||
callSetup = false;
|
||||
hasLuaConfig = false;
|
||||
extraConfig = cfg: {
|
||||
globals.opencode_opts = cfg.settings;
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
port = 8080;
|
||||
auto_reload = false;
|
||||
prompts = {
|
||||
example = {
|
||||
description = "An example prompt configuration";
|
||||
prompt = "Write a function that returns the factorial of a number";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
95
tests/test-sources/plugins/by-name/opencode/default.nix
Normal file
95
tests/test-sources/plugins/by-name/opencode/default.nix
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.opencode.enable = true;
|
||||
};
|
||||
|
||||
defaults = {
|
||||
plugins.opencode = {
|
||||
enable = true;
|
||||
settings = {
|
||||
port = null;
|
||||
auto_reload = true;
|
||||
auto_register_cmp_sources = [
|
||||
"opencode"
|
||||
"buffer"
|
||||
];
|
||||
contexts = {
|
||||
"@buffer" = {
|
||||
description = "Current buffer";
|
||||
value.__raw = ''require("opencode.context").buffer'';
|
||||
};
|
||||
"@buffers" = {
|
||||
description = "Open buffers";
|
||||
value.__raw = ''require("opencode.context").buffers'';
|
||||
};
|
||||
"@cursor" = {
|
||||
description = "Cursor position";
|
||||
value.__raw = ''require("opencode.context").cursor_position'';
|
||||
};
|
||||
"@selection" = {
|
||||
description = "Selected text";
|
||||
value.__raw = ''require("opencode.context").visual_selection'';
|
||||
};
|
||||
"@visible" = {
|
||||
description = "Visible text";
|
||||
value.__raw = ''require("opencode.context").visible_text'';
|
||||
};
|
||||
"@diagnostic" = {
|
||||
description = "Current line diagnostics";
|
||||
value.__raw = ''
|
||||
function()
|
||||
return require("opencode.context").diagnostics(true)
|
||||
end
|
||||
'';
|
||||
};
|
||||
"@diagnostics" = {
|
||||
description = "Current buffer diagnostics";
|
||||
value.__raw = ''require("opencode.context").diagnostics'';
|
||||
};
|
||||
"@quickfix" = {
|
||||
description = "Quickfix list";
|
||||
value.__raw = ''require("opencode.context").quickfix '';
|
||||
};
|
||||
"@diff" = {
|
||||
description = "Git diff";
|
||||
value.__raw = ''require("opencode.context").git_diff '';
|
||||
};
|
||||
"@grapple" = {
|
||||
description = "Grapple tags";
|
||||
value.__raw = ''require("opencode.context").grapple_tags '';
|
||||
};
|
||||
};
|
||||
prompts = {
|
||||
explain = {
|
||||
description = "Explain code near cursor";
|
||||
prompt = "Explain @cursor and its context";
|
||||
};
|
||||
fix = {
|
||||
description = "Fix diagnostics";
|
||||
prompt = "Fix these @diagnostics";
|
||||
};
|
||||
optimize = {
|
||||
description = "Optimize selection";
|
||||
prompt = "Optimize @selection for performance and readability";
|
||||
};
|
||||
document = {
|
||||
description = "Document selection";
|
||||
prompt = "Add documentation comments for @selection";
|
||||
};
|
||||
test = {
|
||||
description = "Add tests for selection";
|
||||
prompt = "Add tests for @selection";
|
||||
};
|
||||
review_buffer = {
|
||||
description = "Review buffer";
|
||||
prompt = "Review @buffer for correctness and readability";
|
||||
};
|
||||
review_diff = {
|
||||
description = "Review git diff";
|
||||
prompt = "Review the following git diff for correctness and readability:\n@diff";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue