Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,18 @@ This changelog starts tracking releases from the point it was introduced.

## Unreleased

- Start tracking changes here.
### Added

- **Note Mode**: Add comments to any codebase files without diff context
- Multiple note sets for different purposes (e.g., "security-audit", "refactoring")
- Persistent storage across Neovim sessions with auto-restore
- Same keymaps and UI as diff review mode for consistency
- Export notes to markdown with optional code context
- New commands: `:DiffNote enter/exit/toggle/clear/list/switch/copy`
- Separate storage from review comments (`.diff-review/notes/`)
- Session persistence and auto-restore on startup (configurable)

### Changed

- Consolidated commands to `:DiffReview` and `:DiffNote` with subcommands
- Improved command completion and help text
220 changes: 181 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,22 @@ require('diff-review').setup()

### Commands

Open the diff review window:
**Main diff review command:**
```vim
:DiffReview
```

Review changes against a specific branch:
```vim
:DiffReview origin/main
```

Review a pull request (requires gh CLI):
```vim
:DiffReviewPR 123
```

Submit PR review comments (PR reviews only):
```vim
:DiffReviewSubmit
```

Toggle diff review window (preserves state):
:DiffReview " Open with prompt to select type
:DiffReview origin/main " Review against branch
:DiffReview pr:123 " Review pull request
:DiffReview close " Close review
:DiffReview toggle " Toggle visibility
:DiffReview list " List/switch reviews
:DiffReview copy [mode] " Copy to clipboard (comments/full/diff)
:DiffReview submit " Submit to GitHub
:DiffReview health " Health check
```

**Shortcut for toggling** (most common operation):
```vim
:DiffReviewToggle
:DiffReviewToggle " Quick toggle (preserves state)
```

### Navigating to Files
Expand Down Expand Up @@ -262,6 +255,12 @@ require('diff-review').setup({
persistence = {
auto_save = true, -- Auto-save comments after each change
},

-- Note mode options
notes = {
default_set = "default", -- Default note set name
auto_restore = true, -- Auto-restore note mode on startup
},
})
```

Expand Down Expand Up @@ -422,24 +421,161 @@ Comments are stored locally in `.diff-review/` directory and persist across sess

### Pull Request Reviews

When reviewing a PR (via `:DiffReviewPR`), you can submit comments directly to GitHub:
When reviewing a PR (via `:DiffReview pr:123`), you can submit comments directly to GitHub:

```vim
:DiffReviewSubmit
:DiffReview submit
```

This requires the [GitHub CLI](https://cli.github.com/) to be installed and authenticated.

## Exporting Comments
## Note Mode

Export all comments to markdown:
Note mode allows you to add comments to any files in your codebase without requiring diff or review context. Perfect for code audits, documentation, learning notes, or refactoring plans.

### Features

- **Works anywhere**: Comment on any file during normal editing, no special layout required
- **Multiple note sets**: Organize notes for different purposes (e.g., "security-audit", "refactoring")
- **Persistent**: Notes auto-save and persist across Neovim sessions
- **Session restore**: Automatically restores note mode on startup (configurable)
- **Same UI**: Reuses diff review keymaps and styling for consistency

### Commands

**All note mode operations:**
```vim
:DiffReviewExport
:DiffNote enter [set] " Enter note mode (default set if not specified)
:DiffNote exit " Exit note mode
:DiffNote toggle [set] " Toggle note mode
:DiffNote clear " Clear all notes in current set
:DiffNote list " List and switch between sets
:DiffNote switch <set> " Switch to a different set
:DiffNote copy [mode] " Copy to clipboard (notes/full)
```

**Examples:**
```vim
:DiffNote enter security-audit " Start security audit notes
:DiffNote toggle " Quick toggle
:DiffNote copy full " Export with code context
```

### Usage

1. **Enter note mode** with `:DiffNote enter [set_name]`
2. **Navigate files normally** (`:edit`, buffer switches, etc.)
3. **Add comments** using the same keymaps as diff review:
- `<leader>c` - Add comment at cursor (or range in visual mode)
- `<leader>e` - Edit comment at cursor
- `<leader>d` - Delete comment at cursor
- `<leader>l` - List comments for current file
- `<leader>v` - View all comments (across all files)
4. **Comments auto-save** on each change
5. **Exit mode** with `:DiffNote exit` or toggle with `:DiffNote toggle`

### Storage

Notes are stored in `.diff-review/notes/` directory:
```
.diff-review/
├── notes/
│ ├── default.json # Default note set
│ ├── security-audit.json # Named set
│ └── refactoring.json # Another named set
```

### Configuration

Configure note mode behavior in your setup:

```lua
require('diff-review').setup({
notes = {
default_set = "default", -- Default note set name
auto_restore = true, -- Auto-restore note mode on startup
},
})
```

### Example Workflows

**Code audit:**
```vim
:DiffNote enter security-audit
" Navigate files and add notes about security concerns
" Notes persist across sessions
```

**Refactoring plan:**
```vim
:DiffNote enter refactoring
" Document areas that need refactoring
" Switch between note sets as needed
:DiffNote switch technical-debt
```

**Learning codebase:**
```vim
:DiffNote enter learning
" Add notes about how things work
" View all notes: <leader>v
```

### Exporting Notes

Copy all notes to clipboard in markdown format:

**Notes only (with line numbers):**
```vim
:DiffNote copy
```

Output format:
```markdown
## Notes

**Note Set:** security-audit
**Date:** 2024-01-15 10:30

---

### src/auth.lua

- Line 45: Potential SQL injection vulnerability
- Lines 60-65: Missing input validation

### src/user.lua

- Line 23: TODO: Add rate limiting

---

**Total:** 3 notes across 2 files
```

**Full export (with code context):**
```vim
:DiffNote copy full
```

Includes 2 lines of code context before/after each note with syntax highlighting.

### Coexistence with Diff Review

Note mode and diff review mode can run simultaneously:
- Separate namespaces prevent conflicts
- Separate storage directories
- Both can be visible at the same time
- No conversion between notes and review comments

## Exporting Comments

Export with annotated diff:
Export all review comments to markdown:
```vim
:DiffReviewExport annotated
:DiffReview copy " Comments with line numbers
:DiffReview copy full " Comments with code context
:DiffReview copy diff " Annotated diff format
```

## Troubleshooting
Expand Down Expand Up @@ -524,17 +660,23 @@ Run `:DiffReviewHealth` to diagnose layout issues and detect session plugins.

```
lua/diff-review/
├── init.lua # Main entry point
├── config.lua # Configuration management
├── layout.lua # Window/buffer management
├── file_list.lua # File list panel with tree/flat views
├── tree_view.lua # Tree structure building and flattening
├── diff.lua # Git diff execution/parsing
├── ui.lua # Comment UI rendering
├── comments.lua # Comment storage and management
├── actions.lua # Comment actions (add/edit/delete)
├── popup.lua # Comment input popup
└── reviews.lua # Review session management
├── init.lua # Main entry point
├── config.lua # Configuration management
├── layout.lua # Window/buffer management
├── file_list.lua # File list panel with tree/flat views
├── tree_view.lua # Tree structure building and flattening
├── diff.lua # Git diff execution/parsing
├── ui.lua # Comment UI rendering (diff review)
├── comments.lua # Comment storage and management
├── actions.lua # Comment actions (add/edit/delete)
├── popup.lua # Comment input popup
├── reviews.lua # Review session management
├── notes.lua # Note storage (note mode)
├── note_mode.lua # Note mode state management
├── note_persistence.lua # Note persistence layer
├── note_ui.lua # Note UI rendering
├── note_actions.lua # Note actions
└── note_export.lua # Note export functionality
```

### Testing Locally
Expand Down
52 changes: 52 additions & 0 deletions doc/diff-review.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ COMMANDS *diff-review-commands*
:DiffReviewSubmit *:DiffReviewSubmit*
Submit review comments to GitHub (PR reviews only).

:DiffNote [subcommand] [args] *:DiffNote*
Note mode operations for commenting on any codebase files.
Subcommands:
enter [set] Enter note mode (default set if not specified)
exit Exit note mode
toggle [set] Toggle note mode on/off
clear Clear all notes in current set
list List and switch between note sets
switch <set> Switch to a different note set
copy [mode] Copy to clipboard (notes/full)

==============================================================================
KEYMAPS *diff-review-keymaps*

Expand All @@ -59,6 +70,14 @@ Diff panel (default):
<leader>l List comments for current file
<leader>v View all comments in quickfix

Note mode (when active):
Same keymaps as diff panel - works in normal buffers during editing
<leader>c Add note at cursor (or range in visual mode)
<leader>e Edit note at cursor
<leader>d Delete note at cursor
<leader>l List notes for current file
<leader>v View all notes across all files

==============================================================================
CONFIGURATION *diff-review-config*

Expand Down Expand Up @@ -111,6 +130,10 @@ All options are optional. Defaults:
tool = "git", -- "git" | "difftastic" | "delta" | "custom"
custom_command = "", -- used when tool = "custom", supports {args}
},
notes = {
default_set = "default", -- Default note set name
auto_restore = true, -- Auto-restore note mode on startup
},
})
<

Expand Down Expand Up @@ -139,6 +162,35 @@ Custom diff tools can be configured with a command string that includes
})
<

==============================================================================
NOTE MODE *diff-review-note-mode*

Note mode allows adding comments to any files during normal editing without
requiring diff or review context. Perfect for code audits, documentation,
learning notes, or refactoring plans.

Features:
- Works in any file during normal editing (no special layout)
- Multiple note sets for different purposes
- Persistent across sessions with auto-restore
- Same keymaps and UI as diff review mode
- Separate storage from review comments

Usage:
1. Enter note mode with :DiffNote enter [set_name]
2. Navigate files normally and add notes with <leader>c
3. Notes auto-save on each change
4. Exit with :DiffNote exit or toggle with :DiffNote toggle

Storage:
Notes are stored in .diff-review/notes/<set_name>.json and persist across
Neovim sessions. Session state (active mode, current set) is saved to
~/.local/share/nvim/diff-review/note_session.json for auto-restore.

Export:
:DiffNote copy Export notes with line numbers
:DiffNote copy full Export notes with code context

==============================================================================
NOTES *diff-review-notes*

Expand Down
Loading