add netrw preview scrolling
This commit is contained in:
parent
44385e1b3d
commit
c48c9451fc
4 changed files with 33 additions and 0 deletions
1
LOG.md
1
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: 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: 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: 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 `<M-j>` / `<M-k>` mappings to scroll the current preview with native `<C-e>` / `<C-y>` behavior while focus remains in the tree. The mappings accept Vim counts and quietly do nothing when no preview exists.
|
||||||
|
|
||||||
## Project-Local Configuration
|
## Project-Local Configuration
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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] 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] 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] Suppress remaining Vim syntax and indent-guide decoration in file previews, restoring prior state on edit
|
||||||
|
- [x] Add count-aware `<M-j>` / `<M-k>` preview scrolling without moving focus from netrw
|
||||||
- [ ] Test the workflow in an actual SSH session
|
- [ ] Test the workflow in an actual SSH session
|
||||||
- [ ] Confirm stock netrw remains understandable when this configuration is unavailable
|
- [ ] Confirm stock netrw remains understandable when this configuration is unavailable
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 |
|
| `p` | Preview the selected file or directory below and enable live cursor updates |
|
||||||
| `j` / `k` | Update an existing preview to the newly selected entry |
|
| `j` / `k` | Update an existing preview to the newly selected entry |
|
||||||
|
| `<M-j>` / `<M-k>` | Scroll the preview down/up without leaving netrw; accepts a count |
|
||||||
| `:pclose` / `<C-w>z` | Close the preview and stop live updates |
|
| `:pclose` / `<C-w>z` | Close the preview and stop live updates |
|
||||||
| `P` | Open file in previous window |
|
| `P` | Open file in previous window |
|
||||||
| `o` | Open file in horizontal split below |
|
| `o` | Open file in horizontal split below |
|
||||||
|
|
|
||||||
|
|
@ -626,6 +626,18 @@ local function schedule_leave_cleanup(state)
|
||||||
end))
|
end))
|
||||||
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 '<C-e>' or '<C-y>')
|
||||||
|
vim.api.nvim_win_call(preview, function()
|
||||||
|
vim.cmd.normal({ args = { tostring(count) .. key }, bang = true })
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function M.setup(buf)
|
function M.setup(buf)
|
||||||
if vim.fn.has('nvim-0.12') == 0 or not is_valid_buffer(buf) then
|
if vim.fn.has('nvim-0.12') == 0 or not is_valid_buffer(buf) then
|
||||||
return false
|
return false
|
||||||
|
|
@ -653,6 +665,24 @@ function M.setup(buf)
|
||||||
silent = true,
|
silent = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<M-j>', function()
|
||||||
|
scroll_preview(1, vim.v.count1)
|
||||||
|
end, {
|
||||||
|
buffer = buf,
|
||||||
|
desc = 'Netrw: Scroll preview down',
|
||||||
|
nowait = true,
|
||||||
|
silent = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<M-k>', 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', {
|
vim.api.nvim_create_autocmd('CursorMoved', {
|
||||||
group = preview_group,
|
group = preview_group,
|
||||||
buffer = buf,
|
buffer = buf,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue