feat(neovim): add opencode.nvim for AI assistant integration - #575
Conversation
📝 WalkthroughSummary by CodeRabbitRelease NotesNew Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThis change adds AI integration to Neovim by configuring three plugins—sidekick.nvim, snacks.nvim, and opencode.nvim—with extensive keybindings for prompting, execution, terminal toggling, and operator modes. Comprehensive tests validate the configuration structure and keymap patterns. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
🔇 Additional comments (7)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Add opencode.nvim plugin from https://github.com/NickvanDyke/opencode.nvim for integrating the opencode AI assistant with Neovim. Features: - Auto-connect to opencode running in Neovim's CWD - Input prompts with completions and highlights - Share editor context (buffer, cursor, selection, diagnostics) - Execute commands and respond to permission requests - Reload edited buffers in real-time Keymaps: - <C-a> - Ask opencode about current context - <C-x> - Execute opencode action from selection menu - <C-.> - Toggle opencode terminal - go/goo - Operator mode for adding ranges - <S-C-u>/<S-C-d> - Scroll opencode session - +/- - Remapped increment/decrement Dependencies: - Added folke/snacks.nvim (required for opencode.nvim) Tests: - Added comprehensive tests for opencode API patterns - Tests for keymap configurations - Tests for context placeholders and prompts Ref: https://x.com/theprimeagen/status/2011538844836143406
Mesa DescriptionTL;DRAdded the What changed?
Description generated by Mesa. Update settings |
There was a problem hiding this comment.
Pull request overview
This PR integrates the opencode.nvim plugin for AI assistant functionality in Neovim. The plugin provides AI-powered code assistance with context-aware prompting, command execution, and real-time buffer synchronization.
Changes:
- Added opencode.nvim and snacks.nvim (dependency) to the plugin list
- Configured opencode.nvim with keymaps for asking, selecting, toggling, and operator modes
- Added comprehensive test coverage for opencode.nvim API patterns, keymaps, and commands
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| home-manager/programs/neovim/lua/plugins.lua | Added snacks.nvim and opencode.nvim to the plugin dependencies in the AI section |
| home-manager/programs/neovim/lua/ai.lua | Configured snacks.nvim and opencode.nvim with keymaps (<C-a>, <C-x>, <C-.>, go, goo) and scroll commands; remapped +/- for increment/decrement |
| home-manager/programs/neovim/tests/ai_spec.lua | Added tests for snacks API structure, opencode API patterns, context placeholders, prompt library, keymaps, and command patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| vim.keymap.set({ "n", "x" }, "go", function() | ||
| return require("opencode").operator("@this ") | ||
| end, { expr = true, desc = "Add range to opencode" }) | ||
|
|
||
| vim.keymap.set("n", "goo", function() | ||
| return require("opencode").operator("@this ") .. "_" | ||
| end, { expr = true, desc = "Add line to opencode" }) |
There was a problem hiding this comment.
The go keymap conflicts with the existing buffer-local go keymap defined in autocmds.lua (line 217) for fugitive buffers. This creates a keybinding collision where the opencode keymap will be shadowed by the fugitive buffer-local mapping. Consider using a different key combination like gO or <leader>go to avoid conflicts.
| vim.keymap.set({ "n", "x" }, "go", function() | |
| return require("opencode").operator("@this ") | |
| end, { expr = true, desc = "Add range to opencode" }) | |
| vim.keymap.set("n", "goo", function() | |
| return require("opencode").operator("@this ") .. "_" | |
| end, { expr = true, desc = "Add line to opencode" }) | |
| vim.keymap.set({ "n", "x" }, "gO", function() | |
| return require("opencode").operator("@this ") | |
| end, { expr = true, desc = "Add range to opencode (gO)" }) | |
| vim.keymap.set("n", "gOO", function() | |
| return require("opencode").operator("@this ") .. "_" | |
| end, { expr = true, desc = "Add line to opencode (gOO)" }) |
| vim.keymap.set("n", "<S-C-u>", function() | ||
| require("opencode").command("session.half.page.up") | ||
| end, { desc = "opencode half page up" }) | ||
|
|
||
| vim.keymap.set("n", "<S-C-d>", function() |
There was a problem hiding this comment.
The <S-C-u> and <S-C-d> keymaps may not work reliably in all terminal emulators. Shift+Ctrl combinations with letter keys are often not distinguishable from their non-shifted counterparts in terminal Neovim. Consider using alternative keymaps that work consistently across terminals, such as <leader>u and <leader>d or using the standard <C-u> and <C-d> with a prefix key.
| vim.keymap.set("n", "<S-C-u>", function() | |
| require("opencode").command("session.half.page.up") | |
| end, { desc = "opencode half page up" }) | |
| vim.keymap.set("n", "<S-C-d>", function() | |
| vim.keymap.set("n", "<leader>u", function() | |
| require("opencode").command("session.half.page.up") | |
| end, { desc = "opencode half page up" }) | |
| vim.keymap.set("n", "<leader>d", function() |
| -- Required for opts.events.reload | ||
| vim.o.autoread = true | ||
|
|
There was a problem hiding this comment.
Setting autoread globally affects all buffers in Neovim, not just opencode buffers. This can cause unexpected behavior where files are automatically reloaded without user confirmation when they change on disk. Consider whether this global setting is necessary, or if opencode.nvim should handle buffer reloading through its own mechanisms without requiring a global option change.
| -- Required for opts.events.reload | |
| vim.o.autoread = true |
There was a problem hiding this comment.
Code Review
This pull request integrates the opencode.nvim plugin for AI assistant functionality. The changes look good overall, adding the necessary plugin dependencies, configuration, and keymaps. However, I've identified a few issues that should be addressed. There's a keymap conflict for <C-.> between opencode.nvim and the existing sidekick.nvim configuration. I also recommend moving the new keymaps to the central keymaps.lua file for consistency. Additionally, the remapping of + and - overrides fundamental Vim motions, which could be disruptive. Finally, several of the new tests are tautological and don't actually test the integration, which could be misleading about test coverage. My detailed comments provide suggestions for resolving these points.
| vim.keymap.set({ "n", "t" }, "<C-.>", function() | ||
| require("opencode").toggle() | ||
| end, { desc = "Toggle opencode" }) |
There was a problem hiding this comment.
This introduces a keymap <C-.> that conflicts with an existing keymap for sidekick defined in keymaps.lua:257. The sidekick mapping is for modes n, t, i, x, while this new mapping is for n, t. Since ai.lua is loaded after keymaps.lua, this mapping will override the sidekick one in normal and terminal modes, but not in insert or visual mode. This leads to inconsistent behavior where <C-.> does different things depending on the mode. This conflict should be resolved by choosing a different keymap for one of the actions or by removing the conflicting one if it's no longer needed.
| -- Keymaps for opencode | ||
| -- <C-a> - Ask opencode about current context | ||
| vim.keymap.set({ "n", "x" }, "<C-a>", function() | ||
| require("opencode").ask("@this: ", { submit = true }) | ||
| end, { desc = "Ask opencode" }) | ||
|
|
||
| -- <C-x> - Execute opencode action from selection menu | ||
| vim.keymap.set({ "n", "x" }, "<C-x>", function() | ||
| require("opencode").select() | ||
| end, { desc = "Execute opencode action…" }) | ||
|
|
||
| -- <C-.> - Toggle opencode terminal | ||
| vim.keymap.set({ "n", "t" }, "<C-.>", function() | ||
| require("opencode").toggle() | ||
| end, { desc = "Toggle opencode" }) | ||
|
|
||
| -- Operator mode: add range to opencode prompt | ||
| vim.keymap.set({ "n", "x" }, "go", function() | ||
| return require("opencode").operator("@this ") | ||
| end, { expr = true, desc = "Add range to opencode" }) | ||
|
|
||
| vim.keymap.set("n", "goo", function() | ||
| return require("opencode").operator("@this ") .. "_" | ||
| end, { expr = true, desc = "Add line to opencode" }) | ||
|
|
||
| -- Scroll keymaps for opencode session | ||
| vim.keymap.set("n", "<S-C-u>", function() | ||
| require("opencode").command("session.half.page.up") | ||
| end, { desc = "opencode half page up" }) | ||
|
|
||
| vim.keymap.set("n", "<S-C-d>", function() | ||
| require("opencode").command("session.half.page.down") | ||
| end, { desc = "opencode half page down" }) | ||
|
|
||
| -- Remap increment/decrement since we use <C-a> and <C-x> for opencode | ||
| vim.keymap.set("n", "+", "<C-a>", { desc = "Increment", noremap = true }) | ||
| vim.keymap.set("n", "-", "<C-x>", { desc = "Decrement", noremap = true }) |
There was a problem hiding this comment.
The keymaps for opencode.nvim are defined here in ai.lua. However, there is a central keymaps.lua file where other keymaps, including those for sidekick, are defined. To maintain consistency and have a single source of truth for keybindings, it would be better to move these opencode.nvim keymaps to keymaps.lua, under a new OPENCODE section. This would also make the <C-.> conflict with sidekick more apparent and easier to manage.
| vim.keymap.set("n", "+", "<C-a>", { desc = "Increment", noremap = true }) | ||
| vim.keymap.set("n", "-", "<C-x>", { desc = "Decrement", noremap = true }) |
There was a problem hiding this comment.
These keymaps override the default behavior of + and - in normal mode, which are standard Vim motions for moving to the next and previous line respectively. While this is documented in the pull request description, it's a significant departure from default Vim behavior that could be disruptive and surprising. Have you considered using different keys for increment/decrement to avoid overriding these built-in motions? For example, <leader>+ and <leader>- could be alternatives that don't clash with default functionality.
| it("should have expected snacks components structure", function() | ||
| -- snacks.nvim provides input, picker, and terminal | ||
| local expected_components = { "input", "picker", "terminal" } | ||
| for _, component in ipairs(expected_components) do | ||
| assert.is_string(component) | ||
| end | ||
| end) |
There was a problem hiding this comment.
The test should have expected snacks components structure is tautological. It defines a local table and then asserts properties of that same table. It doesn't test any interaction with the snacks.nvim plugin or its configuration. This provides no value and can be misleading about test coverage. Please consider removing this test or changing it to assert something meaningful about the integration, if possible within your testing framework.
| it("should support context placeholders pattern", function() | ||
| -- opencode.nvim uses context placeholders like @this, @buffer, etc. | ||
| local placeholders = { | ||
| "@this", | ||
| "@buffer", | ||
| "@buffers", | ||
| "@visible", | ||
| "@diagnostics", | ||
| "@quickfix", | ||
| "@diff", | ||
| "@marks", | ||
| } | ||
| for _, placeholder in ipairs(placeholders) do | ||
| assert.is_string(placeholder) | ||
| assert.is_true(placeholder:sub(1, 1) == "@") | ||
| end | ||
| end) |
There was a problem hiding this comment.
This test for context placeholders is tautological. It defines a local table placeholders and asserts its contents. It doesn't test anything about opencode.nvim itself. This test provides a false sense of coverage as it will pass regardless of the plugin's actual implementation. If the goal is to document the placeholders, a comment in the configuration file would be more appropriate. As a test, this provides little value and should be refactored or removed.
| it("should support prompt library pattern", function() | ||
| -- opencode.nvim includes built-in prompts | ||
| local prompts = { | ||
| "diagnostics", | ||
| "diff", | ||
| "document", | ||
| "explain", | ||
| "fix", | ||
| "implement", | ||
| "optimize", | ||
| "review", | ||
| "test", | ||
| } | ||
| for _, prompt in ipairs(prompts) do | ||
| assert.is_string(prompt) | ||
| end | ||
| end) |
There was a problem hiding this comment.
Similar to other new tests in this file, this test for the prompt library is tautological. It verifies a hardcoded list of strings. This doesn't ensure that opencode.nvim actually provides these prompts or that they are correctly configured. This test is misleading about the actual test coverage and should be removed or refactored to be a meaningful test of the plugin's integration.
There was a problem hiding this comment.
Performed full review of b699cf0...27d7ed9
Analysis
-
Error Handling Vulnerability - The code directly calls
require()without protection (e.g.,pcall), which will cause a hard failure on Neovim startup if dependencies like snacks.nvim or opencode.nvim are not installed. -
Dependency Chain Fragility - There's an implicit dependency chain (opencode.nvim → snacks.nvim) that could lead to undefined behavior if snacks.nvim fails or is removed.
-
Global State Mutation - Setting
vim.o.autoread = trueaffects all buffers system-wide and may have unexpected side effects with other file watchers or external modifications. -
External Binary Dependency - The integration assumes the
opencodebinary exists in PATH without graceful degradation if it's missing. -
Keymap Override Risk - Common Vim keybindings (
<C-a>,<C-x>) are overridden without runtime checks, potentially causing user friction despite the alternative mappings.
Tip
Help
Slash Commands:
/review- Request a full code review/review latest- Review only changes since the last review/describe- Generate PR description. This will update the PR body or issue comment depending on your configuration/help- Get help with Mesa commands and configuration options
0 files reviewed | 3 comments | Edit Agent Settings • Read Docs
|
|
||
| -- Keymaps for opencode | ||
| -- <C-a> - Ask opencode about current context | ||
| vim.keymap.set({ "n", "x" }, "<C-a>", function() |
There was a problem hiding this comment.
The keymaps for opencode should also be wrapped in error handling. If opencode.nvim fails to load, these keymaps will cause runtime errors when triggered. Consider:
local opencode_ok, opencode = pcall(require, "opencode")
if opencode_ok then
vim.keymap.set({ "n", "x" }, "<C-a>", function()
opencode.ask("@this: ", { submit = true })
end, { desc = "Ask opencode" })
-- ... other keymaps
endThis ensures graceful degradation if the plugin is unavailable.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#575
File: home-manager/programs/neovim/lua/ai.lua#L36
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
The keymaps for opencode should also be wrapped in error handling. If opencode.nvim fails to load, these keymaps will cause runtime errors when triggered. Consider:
```lua
local opencode_ok, opencode = pcall(require, "opencode")
if opencode_ok then
vim.keymap.set({ "n", "x" }, "<C-a>", function()
opencode.ask("@this: ", { submit = true })
end, { desc = "Ask opencode" })
-- ... other keymaps
end
This ensures graceful degradation if the plugin is unavailable.
</details>
| } | ||
|
|
||
| -- Required for opts.events.reload | ||
| vim.o.autoread = true |
There was a problem hiding this comment.
Setting vim.o.autoread = true globally affects all buffers in Neovim, not just opencode-related buffers. This means any file modified externally will be automatically reloaded without warning.
While necessary for opencode's reload functionality, this could cause unexpected behavior if users are working with files that are also being modified by external processes. Consider documenting this side effect more prominently, perhaps with a comment explaining the global impact.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#575
File: home-manager/programs/neovim/lua/ai.lua#L32
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
Setting `vim.o.autoread = true` globally affects all buffers in Neovim, not just opencode-related buffers. This means any file modified externally will be automatically reloaded without warning.
While necessary for opencode's reload functionality, this could cause unexpected behavior if users are working with files that are also being modified by external processes. Consider documenting this side effect more prominently, perhaps with a comment explaining the global impact.
| -- SNACKS (Required for opencode.nvim) | ||
| -- From: https://github.com/folke/snacks.nvim | ||
| -- ==================================================================================== | ||
| require("snacks").setup({ |
There was a problem hiding this comment.
Missing error handling for snacks.nvim setup. If the plugin isn't installed, this will cause Neovim to fail on startup. Consider wrapping in pcall() for graceful degradation:
local ok, snacks = pcall(require, "snacks")
if ok then
snacks.setup({
input = {},
picker = {},
terminal = {},
})
else
vim.notify("snacks.nvim not available - opencode.nvim will not function", vim.log.levels.WARN)
endThis pattern is already used elsewhere in the codebase (e.g., utils.lua line 64 for nvim-web-devicons).
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#575
File: home-manager/programs/neovim/lua/ai.lua#L14
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
Missing error handling for snacks.nvim setup. If the plugin isn't installed, this will cause Neovim to fail on startup. Consider wrapping in pcall() for graceful degradation:
```lua
local ok, snacks = pcall(require, "snacks")
if ok then
snacks.setup({
input = {},
picker = {},
terminal = {},
})
else
vim.notify("snacks.nvim not available - opencode.nvim will not function", vim.log.levels.WARN)
end
This pattern is already used elsewhere in the codebase (e.g., utils.lua line 64 for nvim-web-devicons).
</details>
There was a problem hiding this comment.
5 issues found across 3 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="home-manager/programs/neovim/lua/plugins.lua">
<violation number="1" location="home-manager/programs/neovim/lua/plugins.lua:87">
P2: New plugins added without corresponding lock entries—snacks.nvim and opencode.nvim are unpinned, undermining reproducibility.</violation>
</file>
<file name="home-manager/programs/neovim/tests/ai_spec.lua">
<violation number="1" location="home-manager/programs/neovim/tests/ai_spec.lua:18">
P2: AI integration test is tautological: only asserts hardcoded strings are strings, so it cannot fail even if snacks/opencode integrations are broken.</violation>
<violation number="2" location="home-manager/programs/neovim/tests/ai_spec.lua:33">
P2: Test sets vim.o.autoread globally without restoring the prior value, causing state leakage between tests.</violation>
<violation number="3" location="home-manager/programs/neovim/tests/ai_spec.lua:88">
P2: Keymap existence check is unreliable: maparg() returns empty string for Lua callback mappings, so these assertions can fail even when the mapping exists.</violation>
</file>
<file name="home-manager/programs/neovim/lua/ai.lua">
<violation number="1" location="home-manager/programs/neovim/lua/ai.lua:60">
P2: Ctrl+Shift-U/D mappings likely collapse to Ctrl-U/D and override default half-page scroll keys globally, breaking normal navigation.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| { src = "https://github.com/yioneko/nvim-vtsls" }, | ||
|
|
||
| -- AI | ||
| { src = "https://github.com/folke/snacks.nvim" }, -- Required for opencode.nvim |
There was a problem hiding this comment.
P2: New plugins added without corresponding lock entries—snacks.nvim and opencode.nvim are unpinned, undermining reproducibility.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/programs/neovim/lua/plugins.lua, line 87:
<comment>New plugins added without corresponding lock entries—snacks.nvim and opencode.nvim are unpinned, undermining reproducibility.</comment>
<file context>
@@ -84,7 +84,9 @@ vim.pack.add({
{ src = "https://github.com/yioneko/nvim-vtsls" },
-- AI
+ { src = "https://github.com/folke/snacks.nvim" }, -- Required for opencode.nvim
{ src = "https://github.com/folke/sidekick.nvim" },
+ { src = "https://github.com/NickvanDyke/opencode.nvim" },
</file context>
|
|
||
| it("should support autoread option for reload events", function() | ||
| -- Required for opencode reload functionality | ||
| vim.o.autoread = true |
There was a problem hiding this comment.
P2: Test sets vim.o.autoread globally without restoring the prior value, causing state leakage between tests.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/programs/neovim/tests/ai_spec.lua, line 33:
<comment>Test sets vim.o.autoread globally without restoring the prior value, causing state leakage between tests.</comment>
<file context>
@@ -10,6 +10,67 @@ describe("ai", function()
+
+ it("should support autoread option for reload events", function()
+ -- Required for opencode reload functionality
+ vim.o.autoread = true
+ assert.equals(true, vim.o.autoread)
+ end)
</file context>
| -- snacks.nvim provides input, picker, and terminal | ||
| local expected_components = { "input", "picker", "terminal" } | ||
| for _, component in ipairs(expected_components) do | ||
| assert.is_string(component) |
There was a problem hiding this comment.
P2: AI integration test is tautological: only asserts hardcoded strings are strings, so it cannot fail even if snacks/opencode integrations are broken.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/programs/neovim/tests/ai_spec.lua, line 18:
<comment>AI integration test is tautological: only asserts hardcoded strings are strings, so it cannot fail even if snacks/opencode integrations are broken.</comment>
<file context>
@@ -10,6 +10,67 @@ describe("ai", function()
+ -- snacks.nvim provides input, picker, and terminal
+ local expected_components = { "input", "picker", "terminal" }
+ for _, component in ipairs(expected_components) do
+ assert.is_string(component)
+ end
+ end)
</file context>
| vim.keymap.set({ "n", "x" }, "<C-a>", function() end, { desc = "Ask opencode" }) | ||
| local keymap_n = vim.fn.maparg("<C-a>", "n") | ||
| local keymap_x = vim.fn.maparg("<C-a>", "x") | ||
| assert.is_true(keymap_n ~= "") |
There was a problem hiding this comment.
P2: Keymap existence check is unreliable: maparg() returns empty string for Lua callback mappings, so these assertions can fail even when the mapping exists.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/programs/neovim/tests/ai_spec.lua, line 88:
<comment>Keymap existence check is unreliable: maparg() returns empty string for Lua callback mappings, so these assertions can fail even when the mapping exists.</comment>
<file context>
@@ -18,5 +79,75 @@ describe("ai", function()
+ vim.keymap.set({ "n", "x" }, "<C-a>", function() end, { desc = "Ask opencode" })
+ local keymap_n = vim.fn.maparg("<C-a>", "n")
+ local keymap_x = vim.fn.maparg("<C-a>", "x")
+ assert.is_true(keymap_n ~= "")
+ assert.is_true(keymap_x ~= "")
+ vim.keymap.del("n", "<C-a>")
</file context>
| end, { expr = true, desc = "Add line to opencode" }) | ||
|
|
||
| -- Scroll keymaps for opencode session | ||
| vim.keymap.set("n", "<S-C-u>", function() |
There was a problem hiding this comment.
P2: Ctrl+Shift-U/D mappings likely collapse to Ctrl-U/D and override default half-page scroll keys globally, breaking normal navigation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/programs/neovim/lua/ai.lua, line 60:
<comment>Ctrl+Shift-U/D mappings likely collapse to Ctrl-U/D and override default half-page scroll keys globally, breaking normal navigation.</comment>
<file context>
@@ -1,3 +1,70 @@
+end, { expr = true, desc = "Add line to opencode" })
+
+-- Scroll keymaps for opencode session
+vim.keymap.set("n", "<S-C-u>", function()
+ require("opencode").command("session.half.page.up")
+end, { desc = "opencode half page up" })
</file context>
Add opencode.nvim plugin from https://github.com/NickvanDyke/opencode.nvim for integrating the opencode AI assistant with Neovim.
Features
Keymaps
Context Placeholders
opencode.nvim replaces these placeholders in prompts with editor context:
Dependencies
Tests
All tests pass:
```
✓ opencode.nvim API patterns
✓ Context placeholders
✓ Prompt library
✓ All keymap patterns
✓ Command patterns
```
Ref: https://x.com/theprimeagen/status/2011538844836143406
Summary by cubic
Add opencode.nvim to Neovim to enable context-aware prompts, actions, and a terminal for coding assistance. Includes keymaps, context sharing, and tests, and adds the required snacks.nvim dependency.
New Features
Dependencies
Written for commit 27d7ed9. Summary will update on new commits.