nvim agent setup#25
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a ChangesNeovim Context Bridge
Sequence Diagram(s)sequenceDiagram
participant Claude as Claude Assistant
participant nvim_ctx as nvim-ctx script
participant tmux as tmux
participant socket as Neovim Server Socket
participant NvimCtxJSON as v:lua.NvimCtxJSON()
Claude->>nvim_ctx: run nvim-ctx [session]
nvim_ctx->>tmux: list-panes, find nvim pane
tmux-->>nvim_ctx: pane PID
nvim_ctx->>nvim_ctx: resolve nvim PID, search /var/folders for socket
nvim_ctx->>socket: nvim --server <socket> --remote-expr
socket->>NvimCtxJSON: evaluate v:lua.NvimCtxJSON()
NvimCtxJSON-->>socket: JSON {file, start_line, end_line, text}
socket-->>nvim_ctx: JSON string
nvim_ctx-->>Claude: JSON context output
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@nvim/.config/nvim/lua/greg/ctx.lua`:
- Around line 5-16: The code uses stale visual marks (line("'<") and line("'>"))
to detect if a selection is active, but these marks persist from previous
selections even when no selection is currently active. Instead of relying on
mark existence, use Vim's active mode detection to determine if a visual
selection is currently active. Check the current mode using Vim's mode detection
function to distinguish between an active visual selection and a previous
selection that no longer exists, then conditionally fetch either the selected
lines or the entire buffer accordingly.
In `@zsh/.local/bin/nvim-ctx`:
- Around line 17-24: The issue is that line 17 uses pgrep to get the first child
process without verifying it's nvim, which can select the wrong process and
cause line 22 to incorrectly report nvim is not running. Instead of taking the
first child with head -1, modify the pgrep command to filter for child processes
that match the nvim command specifically, or iterate through the child processes
to find the one where the command is nvim, ensuring the correct process is
identified before the verification check on line 22.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: eca9daa3-b61e-48a7-bcd7-40b52159f856
📒 Files selected for processing (4)
claude/.claude/CLAUDE.mdnvim/.config/nvim/lua/greg/ctx.luanvim/.config/nvim/lua/greg/init.luazsh/.local/bin/nvim-ctx
| local sl = vim.fn.line("'<") | ||
| local el = vim.fn.line("'>") | ||
| local file = vim.fn.expand("%:p") | ||
| local text | ||
|
|
||
| if sl == 0 then | ||
| sl = 1 | ||
| el = vim.fn.line("$") | ||
| text = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n") | ||
| else | ||
| text = table.concat(vim.fn.getline(sl, el) --[[@as string[] ]], "\n") | ||
| end |
There was a problem hiding this comment.
Use active mode detection instead of stale visual marks.
Line 10 currently treats any existing '< mark as an active selection. That can return a previous selection during normal-mode remote calls, violating the “selection if active, otherwise full buffer” contract.
Proposed fix
function M.json()
- local sl = vim.fn.line("'<")
- local el = vim.fn.line("'>")
+ local sl = vim.fn.line("'<")
+ local el = vim.fn.line("'>")
local file = vim.fn.expand("%:p")
local text
- if sl == 0 then
+ local mode = vim.api.nvim_get_mode().mode
+ local has_active_visual = (mode == "v" or mode == "V" or mode == "\22")
+
+ if not has_active_visual then
sl = 1
el = vim.fn.line("$")
text = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n")
else
text = table.concat(vim.fn.getline(sl, el) --[[`@as` string[] ]], "\n")
end🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@nvim/.config/nvim/lua/greg/ctx.lua` around lines 5 - 16, The code uses stale
visual marks (line("'<") and line("'>")) to detect if a selection is active, but
these marks persist from previous selections even when no selection is currently
active. Instead of relying on mark existence, use Vim's active mode detection to
determine if a visual selection is currently active. Check the current mode
using Vim's mode detection function to distinguish between an active visual
selection and a previous selection that no longer exists, then conditionally
fetch either the selected lines or the entire buffer accordingly.
Summary by CodeRabbit
Release Notes
:NvimCtxcommand in Neovim to output selected-text context (or full buffer when no selection exists)nvim-ctxutility to fetch Neovim context from the active Neovim session/server