Skip to content

Commit 47bcc7c

Browse files
committed
bunch of fixes:
- fixing the walkthrough to go by highlight - Add AGENTS.md self-documenting file - ignore noisy 'lock' style files by default
1 parent 16a6bb7 commit 47bcc7c

File tree

9 files changed

+565
-23
lines changed

9 files changed

+565
-23
lines changed

AGENTS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414

1515
- `toggle_prev_code()` is a global review-mode toggle: it flips `show_old_code` and applies to all hunks in applied review buffers, not just the currently selected change block.
1616

17+
## Learned while implementing Ask walkthrough navigation
18+
19+
- `next_change`/`prev_change` route through `ui/walkthrough.lua` when Ask is open, so anchor-level behavior must live in `next_step`/`prev_step`; changing `ui/nav.lua` alone will not affect Ask navigation.
20+
21+
## Learned while implementing local diff noise filtering
22+
23+
- Filter `ReviewDiff` files before `state.set_local_review()` and before optional AI analysis so navigation, change counts, and AI walkthrough inputs stay consistent.
24+
- Basename-based skipping is sufficient for lockfiles: matching both exact path and `"/" .. basename` suffix excludes nested lockfiles without adding glob parsing complexity.
25+
1726
## Project Overview
1827

1928
`neo-reviewer` is a Neovim plugin for reviewing GitHub PRs. Hybrid architecture: Rust CLI for GitHub API/diff parsing, Lua plugin for UI.

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ require("neo_reviewer").setup({
7575
},
7676
wrap_navigation = true, -- Wrap at file boundaries
7777
auto_expand_deletes = false, -- Auto-expand deleted lines
78+
review_diff = {
79+
skip_noise_files = true, -- Skip common lock/noise files by default
80+
noise_files = {
81+
"pnpm-lock.yaml",
82+
"Cargo.lock",
83+
},
84+
},
7885
})
7986
```
8087

@@ -137,7 +144,7 @@ vim.keymap.set("n", ",dx", nr.request_changes, vim.tbl_extend("force", opts, { d
137144
| Command | Description |
138145
|---------|-------------|
139146
| `:ReviewPR {url}` | Open a PR for review |
140-
| `:ReviewDiff` | Review local git diff |
147+
| `:ReviewDiff` | Review local git diff (skips configured noise files by default) |
141148
| `:Ask` | AI-guided codebase exploration |
142149
| `:AddComment` | Add a review comment |
143150
| `:Approve` | Approve the PR |

doc/neo_reviewer.txt

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ Call setup() with your options: >lua
8888
cancel = "<Esc>", -- Key to cancel input
8989
},
9090
},
91+
review_diff = {
92+
skip_noise_files = true, -- Skip common lock/noise files by default
93+
noise_files = {
94+
"pnpm-lock.yaml",
95+
"Cargo.lock",
96+
},
97+
},
9198
ai = {
9299
enabled = false, -- Run AI analysis by default
93100
model = "gpt-5.3-codex", -- Model for Codex CLI (default)
@@ -117,6 +124,14 @@ input_window.keys ~
117124
- `submit`: Key to submit the input (default: "<C-s>").
118125
- `cancel`: Key to cancel and close the input window (default: "<Esc>").
119126

127+
*neo_reviewer-config-review_diff*
128+
review_diff ~
129+
Configure local diff review file filtering.
130+
- `skip_noise_files`: Skip common lock/noise files in |:ReviewDiff|
131+
(default: true).
132+
- `noise_files`: Basenames to skip when `skip_noise_files` is enabled.
133+
Any file with a matching basename is excluded from local diff review.
134+
120135
*neo_reviewer-config-ai*
121136
ai ~
122137
Configure AI-powered review analysis. Requires an AI CLI (Codex CLI by
@@ -172,7 +187,10 @@ These user commands are created when you call `setup()`.
172187

173188
:ReviewDiff [--analyze|--no-analyze] *:ReviewDiff*
174189
Review local git diff (both staged and unstaged changes). Comments are
175-
written to `REVIEW_COMMENTS.md` in the project root.
190+
written to `REVIEW_COMMENTS.md` in the project root. By default, common
191+
lock/noise files (for example `pnpm-lock.yaml`, `Cargo.lock`) are skipped.
192+
Configure this via `review_diff.skip_noise_files` and
193+
`review_diff.noise_files`.
176194
- `--analyze`: Force AI analysis on (overrides config)
177195
- `--no-analyze`: Force AI analysis off (overrides config)
178196

@@ -192,7 +210,8 @@ These user commands are created when you call `setup()`.
192210
loading message. When ready, the first step jumps to its first anchor
193211
(if any).
194212
When the exploration window is open, |neo_reviewer.next_change()| and
195-
|neo_reviewer.prev_change()| navigate between exploration steps.
213+
|neo_reviewer.prev_change()| move through anchors in the current step
214+
first, then move between exploration steps.
196215

197216
:AddComment *:AddComment*
198217
Add a review comment at cursor position. Supports visual range selection
@@ -231,7 +250,9 @@ require("neo_reviewer").review_pr({arg}) *neo_reviewer.review_
231250

232251
require("neo_reviewer").review_diff({opts}) *neo_reviewer.review_diff()*
233252
Review local git diff (both staged and unstaged changes). This allows
234-
you to review code changes before committing. Accepts optional {opts}:
253+
you to review code changes before committing. By default, common lock/noise
254+
files are skipped using `review_diff.skip_noise_files` and
255+
`review_diff.noise_files`. Accepts optional {opts}:
235256
- `analyze`: boolean to force AI analysis on/off (overrides config)
236257

237258
Comments are written to `REVIEW_COMMENTS.md` in the project root with
@@ -255,10 +276,14 @@ require("neo_reviewer").ask({opts}) *neo_reviewer.ask()*
255276
The file is cleared each time you start a new local diff review.
256277

257278
require("neo_reviewer").next_change() *neo_reviewer.next_change()*
258-
Jump to the next contiguous block of changes.
279+
Jump to the next contiguous block of changes. When an Ask walkthrough is
280+
open, this moves to the next anchor in the current step before advancing
281+
to the next step.
259282

260283
require("neo_reviewer").prev_change() *neo_reviewer.prev_change()*
261-
Jump to the previous contiguous block of changes.
284+
Jump to the previous contiguous block of changes. When an Ask walkthrough
285+
is open, this moves to the previous anchor in the current step before
286+
moving to the previous step.
262287

263288
require("neo_reviewer").next_comment() *neo_reviewer.next_comment()*
264289
Jump to the next comment in the review. Works in both PR review mode

lua/neo_reviewer/config.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@
3030
---@field height integer Minimum height of the walkthrough split (0 = auto)
3131
---@field focus_on_open boolean Whether to focus the walkthrough window on open
3232

33+
---@class NRReviewDiff
34+
---@field skip_noise_files boolean Whether to skip common lock/noise files in local diff reviews
35+
---@field noise_files string[] Basenames to skip in local diff reviews when skip_noise_files is enabled
36+
3337
---@class NRConfig
3438
---@field cli_path string Path to the neo-reviewer CLI binary
3539
---@field signs NRSigns
3640
---@field wrap_navigation boolean Whether to wrap around when navigating change blocks
3741
---@field auto_expand_deletes boolean Whether to auto-expand deleted lines
3842
---@field thread_window NRThreadWindow
3943
---@field input_window NRInputWindow
44+
---@field review_diff NRReviewDiff
4045
---@field ai NRAI AI analysis configuration
4146

4247
---@class NRPartialSigns
@@ -64,6 +69,10 @@
6469
---@field height? integer Minimum height of the walkthrough split (0 = auto)
6570
---@field focus_on_open? boolean Whether to focus the walkthrough window on open
6671

72+
---@class NRPartialReviewDiff
73+
---@field skip_noise_files? boolean Whether to skip common lock/noise files in local diff reviews
74+
---@field noise_files? string[] Basenames to skip in local diff reviews when skip_noise_files is enabled
75+
6776
---@class NRPartialAI
6877
---@field enabled? boolean Whether AI analysis is enabled by default
6978
---@field model? string Model for AI CLI
@@ -78,6 +87,7 @@
7887
---@field auto_expand_deletes? boolean Whether to auto-expand deleted lines
7988
---@field thread_window? NRPartialThreadWindow
8089
---@field input_window? NRPartialInputWindow
90+
---@field review_diff? NRPartialReviewDiff
8191
---@field ai? NRPartialAI AI analysis configuration
8292

8393
---@class NRConfigModule
@@ -109,6 +119,41 @@ M.values = {
109119
cancel = "<Esc>",
110120
},
111121
},
122+
review_diff = {
123+
skip_noise_files = true,
124+
noise_files = {
125+
"pnpm-lock.yaml",
126+
"pnpm-lock.yml",
127+
"package-lock.json",
128+
"npm-shrinkwrap.json",
129+
"yarn.lock",
130+
"bun.lock",
131+
"bun.lockb",
132+
"Cargo.lock",
133+
"Gemfile.lock",
134+
"Pipfile.lock",
135+
"poetry.lock",
136+
"uv.lock",
137+
"pdm.lock",
138+
"composer.lock",
139+
"go.sum",
140+
"Gopkg.lock",
141+
"mix.lock",
142+
"pubspec.lock",
143+
"Podfile.lock",
144+
"Package.resolved",
145+
"packages.lock.json",
146+
"paket.lock",
147+
"gradle.lockfile",
148+
"deps.lock",
149+
"Chart.lock",
150+
"renv.lock",
151+
"conan.lock",
152+
"vcpkg-lock.json",
153+
"flake.lock",
154+
".terraform.lock.hcl",
155+
},
156+
},
112157
ai = {
113158
enabled = false,
114159
model = "gpt-5.3-codex",

lua/neo_reviewer/init.lua

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,49 @@ local function is_github_url(input)
2323
return input:match("github%.com") ~= nil or input:match("^https?://") ~= nil
2424
end
2525

26+
---@param file_path string
27+
---@param noise_file string
28+
---@return boolean
29+
local function path_matches_noise_file(file_path, noise_file)
30+
if file_path == noise_file then
31+
return true
32+
end
33+
34+
local suffix = "/" .. noise_file
35+
return file_path:sub(-#suffix) == suffix
36+
end
37+
38+
---@param files NRFile[]
39+
---@param review_diff_cfg NRReviewDiff
40+
---@return NRFile[] filtered_files
41+
---@return integer skipped_count
42+
local function filter_local_diff_files(files, review_diff_cfg)
43+
if not review_diff_cfg.skip_noise_files then
44+
return files, 0
45+
end
46+
47+
local filtered_files = {}
48+
local skipped_count = 0
49+
50+
for _, file in ipairs(files) do
51+
local skip_file = false
52+
for _, noise_file in ipairs(review_diff_cfg.noise_files or {}) do
53+
if path_matches_noise_file(file.path, noise_file) then
54+
skip_file = true
55+
break
56+
end
57+
end
58+
59+
if skip_file then
60+
skipped_count = skipped_count + 1
61+
else
62+
table.insert(filtered_files, file)
63+
end
64+
end
65+
66+
return filtered_files, skipped_count
67+
end
68+
2669
---@param review NRReview
2770
---@return boolean
2871
local function restore_previous_branch(review)
@@ -321,8 +364,30 @@ function M.review_diff(opts)
321364
return
322365
end
323366

367+
local filtered_files, skipped_count = filter_local_diff_files(data.files, config.values.review_diff)
368+
if #filtered_files == 0 then
369+
vim.notify(
370+
string.format("No reviewable changes after skipping %d noise files", skipped_count),
371+
vim.log.levels.WARN
372+
)
373+
return
374+
end
375+
376+
if skipped_count > 0 then
377+
vim.notify(
378+
string.format("[neo-reviewer] Skipped %d noise file(s) in local diff review", skipped_count),
379+
vim.log.levels.INFO
380+
)
381+
end
382+
383+
---@type NRDiffData
384+
local filtered_data = {
385+
git_root = data.git_root,
386+
files = filtered_files,
387+
}
388+
324389
state.clear_review()
325-
local review = state.set_local_review(data)
390+
local review = state.set_local_review(filtered_data)
326391

327392
local comments_file = require("neo_reviewer.ui.comments_file")
328393
comments_file.clear()
@@ -333,14 +398,28 @@ function M.review_diff(opts)
333398
end
334399

335400
local total_changes = 0
336-
for _, file in ipairs(data.files) do
401+
for _, file in ipairs(filtered_files) do
337402
total_changes = total_changes + #(file.change_blocks or {})
338403
end
339404

340405
local function finish_setup()
341406
M.enable_overlay()
342407

343-
vim.notify(string.format("Local diff review enabled (%d files changed)", #data.files), vim.log.levels.INFO)
408+
if skipped_count > 0 then
409+
vim.notify(
410+
string.format(
411+
"Local diff review enabled (%d files changed, %d noise files skipped)",
412+
#filtered_files,
413+
skipped_count
414+
),
415+
vim.log.levels.INFO
416+
)
417+
else
418+
vim.notify(
419+
string.format("Local diff review enabled (%d files changed)", #filtered_files),
420+
vim.log.levels.INFO
421+
)
422+
end
344423

345424
local nav = require("neo_reviewer.ui.nav")
346425
nav.first_change()
@@ -350,7 +429,7 @@ function M.review_diff(opts)
350429
vim.notify(
351430
string.format(
352431
"[neo-reviewer] Local diff fetched (%d files, %d changes). Running AI analysis...",
353-
#data.files,
432+
#filtered_files,
354433
total_changes
355434
),
356435
vim.log.levels.INFO

0 commit comments

Comments
 (0)