diff --git a/LOG.md b/LOG.md index 3abc341..6ff9515 100644 --- a/LOG.md +++ b/LOG.md @@ -218,6 +218,7 @@ Record every decision here with a short rationale. Append new entries; do not re - 2026-10-28: Fixed a reproducible Neovim 0.12 Tree-sitter race during rapid cross-language netrw previews. Native `:pedit` unloads the previous preview buffer while its asynchronous parser may still be running, producing `TSNode:range()` errors. Preview-only file buffers are now kept loaded but unlisted for the rest of the Neovim session, with Tree-sitter highlighting suspended in favor of Vim syntax; avoiding parser detachment is necessary because delayed unloading reproduces the same race. Pre-existing buffer state is preserved, while entering a previewed file for real editing restores listed-buffer behavior and Tree-sitter immediately. An 80-step Markdown/Lua/JSON preview stress test, edit restoration check, retained-buffer check, and pre-existing-buffer check all pass. - 2026-10-28: Disabled diagnostic rendering in netrw file preview buffers. The preview metadata records each buffer's prior diagnostic state and restores it when the file is opened for editing, keeping ephemeral previews quiet without overriding buffers where diagnostics were already disabled. - 2026-10-28: Made netrw file previews intentionally plain after CSS and HTML exposed residual colour. The remaining decoration was Vim regex syntax plus indent-blankline extmarks, not diagnostics or Tree-sitter. Preview buffers now clear `syntax` and disable their buffer-local indent guides, then restore both recorded states on real edit. +- 2026-10-28: Added buffer-local netrw `` / `` mappings to scroll the current preview with native `` / `` behavior while focus remains in the tree. The mappings accept Vim counts and quietly do nothing when no preview exists. ## Project-Local Configuration diff --git a/MIGRATION_PLAN.md b/MIGRATION_PLAN.md index 45417aa..9e13b18 100644 --- a/MIGRATION_PLAN.md +++ b/MIGRATION_PLAN.md @@ -669,6 +669,7 @@ file 3.2K 2026-10-27 12:55 telescope.lua - [x] Prevent Tree-sitter parser races during rapid cross-language file preview replacement and restore highlighting on edit - [x] Hide diagnostics in file previews and restore their prior per-buffer state on edit - [x] Suppress remaining Vim syntax and indent-guide decoration in file previews, restoring prior state on edit +- [x] Add count-aware `` / `` preview scrolling without moving focus from netrw - [ ] Test the workflow in an actual SSH session - [ ] Confirm stock netrw remains understandable when this configuration is unavailable diff --git a/README.md b/README.md index d66a27c..f7f9e66 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ Core keymaps available globally (not plugin-specific). These provide fallbacks f | --- | --- | | `p` | Preview the selected file or directory below and enable live cursor updates | | `j` / `k` | Update an existing preview to the newly selected entry | +| `` / `` | Scroll the preview down/up without leaving netrw; accepts a count | | `:pclose` / `z` | Close the preview and stop live updates | | `P` | Open file in previous window | | `o` | Open file in horizontal split below | diff --git a/lua/netrw-preview.lua b/lua/netrw-preview.lua index 30c75cb..1dfae69 100644 --- a/lua/netrw-preview.lua +++ b/lua/netrw-preview.lua @@ -626,6 +626,18 @@ local function schedule_leave_cleanup(state) end)) end +local function scroll_preview(direction, count) + local preview = find_preview_window(vim.api.nvim_get_current_tabpage()) + if not preview then + return + end + + local key = vim.keycode(direction > 0 and '' or '') + vim.api.nvim_win_call(preview, function() + vim.cmd.normal({ args = { tostring(count) .. key }, bang = true }) + end) +end + function M.setup(buf) if vim.fn.has('nvim-0.12') == 0 or not is_valid_buffer(buf) then return false @@ -653,6 +665,24 @@ function M.setup(buf) silent = true, }) + vim.keymap.set('n', '', function() + scroll_preview(1, vim.v.count1) + end, { + buffer = buf, + desc = 'Netrw: Scroll preview down', + nowait = true, + silent = true, + }) + + vim.keymap.set('n', '', function() + scroll_preview(-1, vim.v.count1) + end, { + buffer = buf, + desc = 'Netrw: Scroll preview up', + nowait = true, + silent = true, + }) + vim.api.nvim_create_autocmd('CursorMoved', { group = preview_group, buffer = buf,