Skip to content

misc previewer fixes#2667

Merged
phanen merged 5 commits intomainfrom
misc-previewer
Apr 15, 2026
Merged

misc previewer fixes#2667
phanen merged 5 commits intomainfrom
misc-previewer

Conversation

@phanen
Copy link
Copy Markdown
Collaborator

@phanen phanen commented Apr 15, 2026

  • fix(highlights): force verbose=0 to show correct info
  • feat(previewer): improve vimscript keymap preview
  • feat(previewer): improve autocmds preview
  • fix(actions): autocmd "" hacks

Summary by CodeRabbit

  • Bug Fixes

    • Fixed path normalization and sentinel handling in file actions.
    • Improved autocmd preview rendering and fallback when source file info is unavailable.
  • Improvements

    • Enhanced keymap lookup and previews (now shown as Lua content for readability).
    • More robust colorscheme highlight detection.
  • Documentation

    • Expanded keymap entry type to include buffer/file fields.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b320ef6-264e-4abc-8577-7304a6604fe2

📥 Commits

Reviewing files that changed from the base of the PR and between e8d0dfc and c51a408.

📒 Files selected for processing (2)
  • lua/fzf-lua/path.lua
  • lua/fzf-lua/previewer/builtin.lua

📝 Walkthrough

Walkthrough

Relocates a sentinel check in vimcmd entry processing, replaces verbose keymap parsing with vim.fn.maparg and direct Lua callback inspection, adapts previewer parsing to the new keymap format, wraps highlight execution in a verbose = 0 context, and extends the keymap Entry type to inherit buffer/file fields.

Changes

Cohort / File(s) Summary
Keymap lookup & types
lua/fzf-lua/path.lua, lua/fzf-lua/types.lua
M.keymap_to_entry signature simplified to str, switches from parsing verbose {mode}map to vim.fn.maparg and direct debug.getinfo for Lua callbacks; keymap Entry type now inherits fzf-lua.buffer_or_file.Entry.
Previewer parsing
lua/fzf-lua/previewer/builtin.lua
Updated autocmds.parse_entry and keymaps.parse_entry to match new keymap/autocmd entry shapes; changed some return shapes (cache_key/content vs path) and keymap filetype to "lua".
vimcmd entry path handling
lua/fzf-lua/actions.lua
Moved the "<none>" sentinel check to occur after making fullpath relative and normalizing, altering which computed value triggers the early return.
Highlight provider
lua/fzf-lua/providers/colorschemes.lua
Wrapped highlight extraction in a utils.with({ o = { verbose = 0 } }, ...) context when calling nvim_exec2("highlight").

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • ibhagwan

Poem

🐰 I hopped through maps and verbose streams,

swapped whispers for direct Lua beams,
paths now check their truth in line,
highlights quieted, types align—
a rabbit's tidy refactor dreams.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'misc previewer fixes' is vague and generic, using the non-descriptive term 'misc' without conveying specific information about what was actually fixed or improved. Consider using a more specific title that highlights the main change, such as 'Improve previewer handling for keymaps and autocmds' or 'Fix highlight verbose mode and enhance keymap/autocmd previews'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch misc-previewer

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lua/fzf-lua/path.lua (1)

669-691: ⚠️ Potential issue | 🟡 Minor

Remove unused opts argument in actions.lua call to keymap_to_entry.

The function signature at path.lua:670 accepts only str, but the call site in actions.lua:694 still passes a second opts argument:

local entry = path.keymap_to_entry(selected[1], opts)

Change to:

local entry = path.keymap_to_entry(selected[1])

The call site in previewer/builtin.lua:1898 correctly uses the single-argument signature.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lua/fzf-lua/path.lua` around lines 669 - 691, The call to
path.keymap_to_entry is passing an unused second argument; update the call in
actions.lua (the line that currently does local entry =
path.keymap_to_entry(selected[1], opts)) to pass only the string: local entry =
path.keymap_to_entry(selected[1]); ensure you only remove the extra opts
argument and verify there are no other call sites passing a second parameter to
M.keymap_to_entry (function keymap_to_entry in path.lua) so signatures remain
consistent.
🧹 Nitpick comments (1)
lua/fzf-lua/path.lua (1)

682-690: Implementation uses vim.fn.maparg effectively.

The switch from verbose map parsing to vim.fn.maparg(keymap, mode, false, true) is cleaner and more reliable. The Lua callback detection via debug.getinfo correctly extracts source file and line number for jump-to-definition functionality.

Minor note: Line 689's comment -- if entry then return M.entry_to_file(entry, opts) end appears to be leftover from the refactor and could be removed.

🧹 Remove stale comment
     end
   end
-  -- if entry then return M.entry_to_file(entry, opts) end
   return { mode = mode, key = keymap, vmap = vim.inspect(vmap) }
 end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lua/fzf-lua/path.lua` around lines 682 - 690, Remove the leftover commented
code on the final return path: delete the stale comment line "-- if entry then
return M.entry_to_file(entry, opts) end" so the function only uses the vmap /
debug.getinfo logic; ensure nothing else is dependent on M.entry_to_file and
leave the rest of the block (vmap = vim.fn.maparg(...), debug.getinfo handling,
and the final return { mode = mode, key = keymap, vmap = vim.inspect(vmap) })
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lua/fzf-lua/providers/colorschemes.lua`:
- Around line 102-104: The fallback path for utils.with doesn't enforce
verbose=0 so highlight output can be incorrect; patch the highlights retrieval
(the utils.with call that invokes vim.api.nvim_exec2) to ensure verbose=0 is
always applied: if vim._with is available use it, otherwise temporarily save
vim.o.verbose, set vim.o.verbose = 0, call vim.api.nvim_exec2("highlight", {
output = true }), then restore the original vim.o.verbose; keep this change
local to the highlights call so utils.with and the highlights variable behave
the same across Neovim versions.

---

Outside diff comments:
In `@lua/fzf-lua/path.lua`:
- Around line 669-691: The call to path.keymap_to_entry is passing an unused
second argument; update the call in actions.lua (the line that currently does
local entry = path.keymap_to_entry(selected[1], opts)) to pass only the string:
local entry = path.keymap_to_entry(selected[1]); ensure you only remove the
extra opts argument and verify there are no other call sites passing a second
parameter to M.keymap_to_entry (function keymap_to_entry in path.lua) so
signatures remain consistent.

---

Nitpick comments:
In `@lua/fzf-lua/path.lua`:
- Around line 682-690: Remove the leftover commented code on the final return
path: delete the stale comment line "-- if entry then return
M.entry_to_file(entry, opts) end" so the function only uses the vmap /
debug.getinfo logic; ensure nothing else is dependent on M.entry_to_file and
leave the rest of the block (vmap = vim.fn.maparg(...), debug.getinfo handling,
and the final return { mode = mode, key = keymap, vmap = vim.inspect(vmap) })
unchanged.
🪄 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: 1bb3f6ab-ad20-4da2-9265-9c8c1b159d50

📥 Commits

Reviewing files that changed from the base of the PR and between 4be0a69 and e8d0dfc.

📒 Files selected for processing (5)
  • lua/fzf-lua/actions.lua
  • lua/fzf-lua/path.lua
  • lua/fzf-lua/previewer/builtin.lua
  • lua/fzf-lua/providers/colorschemes.lua
  • lua/fzf-lua/types.lua

Comment thread lua/fzf-lua/providers/colorschemes.lua
@phanen phanen marked this pull request as draft April 15, 2026 09:49
@phanen
Copy link
Copy Markdown
Collaborator Author

phanen commented Apr 15, 2026

:verb output don't always output enough information, because information won't be stored before you run e.g. set_keymap with verb>=1
https://github.com/neovim/neovim/blob/64d55b74d83d566975e269bed0810d9008119ddf/src/nvim/lua/executor.c#L2151-L2164
For more information, user have to start nvim with verb>=1 (but not set interactively).

@phanen phanen marked this pull request as ready for review April 15, 2026 10:23
@phanen phanen merged commit 6048a5b into main Apr 15, 2026
9 of 11 checks passed
@phanen phanen deleted the misc-previewer branch April 15, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant