You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add code reference picker for navigating file references in AI responses (#151)
* feat: adds code reference picker to navigate file:line references in LLM responses
* feat(config): add system prompt for file URI navigation
- introduce a new configurable system prompt to customize assistant behavior
- include guidance for file referencing to assist users with integration
- modifies message sending logic to incorporate the system prompt if set
- changes to reference detection streamline navigation for file-related responses
* fix(reference_picker): clean up display formatting
- Remove dead code referencing non-existent ref.context field
- Only show line number in display when present (avoid 'path:?')
* feat(references): parse references on message completion and display icons
- Parse file references when session becomes idle (AI done responding)
- Cache parsed references per-message for faster picker opening
- Handle session load from previous sessions
- Display reference icon before recognized file paths in output
- Subscribe to 'messages' state changes to parse loaded sessions
- Update test expected data files with new icon rendering
* refactor(references): simplify to only support file:// URIs
Remove legacy path:line and path-only pattern detection in favor of
exclusively parsing file:// URIs. This simplifies the code significantly
and avoids false positives from ambiguous path patterns.
The system prompt instructs the LLM to use file:// URIs, making the
legacy patterns unnecessary.
* docs(config): clarify system prompt behavior in config.lua
- refine explanation for system prompt usage in assistant responses
- emphasize file URI scheme for better navigation and tooling integration
* feat(config): update system prompt for file referencing in responses
- remove old system prompt setting in configuration
- replace it with a hardcoded prompt including URI format examples
- modifies behavior to improve navigation and tooling integration
* feat(ui): enhance file URI parsing to support line ranges
- add support for line range format: file://path:start-end
- modify regex pattern to accommodate optional end line numbers
- update reference structure to include optional end_pos for highlighting
* fix(core): update guidance for file reference formatting
- enhance clarity in the instructions for referencing files
- emphasize the use of the file:// URI scheme as critical
- provide examples to illustrate correct and incorrect formats
- ensure compatibility with the existing reference picker for navigation
* fix(ui): enhance reference formatting in picker
- improve reference location display by including line and column info
- handle cases where end position is available for better accuracy
- simplify display logic to ensure consistent output for references
* feat(ui): add preview support to telescope picker
- populate entry path, lnum, and col in telescope entries to support previewers
- enable file previewer configuration when options request file preview
- ensures code references can be previewed directly in the telescope picker UI
* fix(core): mandate backticks for file references in system prompt
- update system prompt to explicitly require backticks around file:// URIs
- add examples distinguishing correct backticked format from incorrect ones
- ensures file references are consistently formatted for UI and parsing
* feat(readme): update key bindings and add functionality details
- add key binding for timeline picker with `<leader>oT`
- include new key binding for browsing code references with `gr`
- clarify command usage for creating and selecting sessions
- touches(config): update default keyboard shortcuts for new features
* test: regenerate expected snapshots after upstream merge
Icon characters changed in upstream, requiring test snapshot updates
* feat(ui): fix icon merge
* test: update snapshots after icon fix
* feat: add telescope support for code range highlighting
Telescope supports highlighting line ranges in the file previewer using
the lnend field. Map end_pos[1] to lnend so that references with line
ranges (file://path:start-end) get highlighted in Telescope previewer.
* fix: use vim_buffer_vimgrep previewer for range highlighting
The default file_previewer uses the 'cat' previewer which doesn't call
jump_to_line, so lnend field is ignored. Switch to vim_buffer_vimgrep
which properly highlights line ranges using the lnend field.
* chore: trigger CI rerun
* feat: add fzf-lua file preview and line navigation support
Add builtin previewer support to fzf-lua picker backend with automatic
line/column positioning for code references.
Changes:
- Enable 'builtin' previewer when preview='file'
- Append file:line:col: format to entries for fzf-lua parsing
- Update fn_fzf_index to strip position info before matching
- Supports navigation to specific lines (range highlighting shows start line only)
Implementation details:
- Uses tab separator between display text and file position
- fzf-lua's entry_to_file() automatically parses path:line:col: format
- Cursorline highlights the target line in preview
- Gracefully degrades when preview is disabled
Comparison with other pickers:
- Telescope: Full range highlighting (start-end lines)
- Snacks: Full range highlighting (start-end lines)
- fzf-lua: Single line highlighting (cursorline at start)
- Mini.pick: No file preview support
* fix: use nbsp separator for fzf-lua entries (not tab)
fzf-lua uses nbsp (U+2002 EN SPACE) as the standard separator between
display text and file path info, not tab. The builtin previewer parses
entries by splitting on utils.nbsp and extracting the path:line:col:
portion.
From fzf-lua/path.lua entry_to_file():
local parts = utils.strsplit(entry, utils.nbsp)
for i = 1, #parts - 1 do
if s:match(".-:%d+:") then break end
idx0 = idx0 + #s + #utils.nbsp
end
return entry:sub(idx0), idx0
Changes:
- Use nbsp (\xe2\x80\x82) instead of \t as separator
- Update fn_fzf_index to split by nbsp
- Use file_path (relative) before file (absolute) for correct resolution
This fixes 'Unable to stat file' errors in preview.
0 commit comments