toggle netrw previews with p
This commit is contained in:
parent
bf39cd1ecd
commit
f35ad357bd
4 changed files with 16 additions and 7 deletions
1
LOG.md
1
LOG.md
|
|
@ -221,6 +221,7 @@ Record every decision here with a short rationale. Append new entries; do not re
|
||||||
- 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.
|
- 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.
|
||||||
- 2026-10-28: Hardened preview scrolling after an interactive over-scroll surfaced a window-local error that did not reproduce headlessly. The temporary preview-window call is now protected, so stale-window and boundary failures are treated like native top/bottom clamping instead of reaching the command line.
|
- 2026-10-28: Hardened preview scrolling after an interactive over-scroll surfaced a window-local error that did not reproduce headlessly. The temporary preview-window call is now protected, so stale-window and boundary failures are treated like native top/bottom clamping instead of reaching the command line.
|
||||||
- 2026-10-28: Excluded netrw from automatic session persistence after `:mksession` serialized its generated `NetrwTreeListing` name and restored an empty explorer buffer. Before the existing exit-time save, preview windows and netrw windows are removed; a netrw-only tab is dropped, while the sole remaining netrw window is replaced with an ordinary file buffer or a blank fallback. Netrw is intentionally not rebuilt on load.
|
- 2026-10-28: Excluded netrw from automatic session persistence after `:mksession` serialized its generated `NetrwTreeListing` name and restored an empty explorer buffer. Before the existing exit-time save, preview windows and netrw windows are removed; a netrw-only tab is dropped, while the sole remaining netrw window is replaced with an ordinary file buffer or a blank fallback. Netrw is intentionally not rebuilt on load.
|
||||||
|
- 2026-10-28: Changed the enhanced netrw `p` mapping into a true toggle. With no preview it opens the selected file or directory and begins live cursor updates; with an existing preview it closes that window and stops updates, matching manual `:pclose` behavior.
|
||||||
|
|
||||||
## Project-Local Configuration
|
## Project-Local Configuration
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -610,7 +610,7 @@ Installed layout:
|
||||||
Target workflow:
|
Target workflow:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
p on file/directory open preview and begin live updates
|
p on file/directory toggle preview and live updates
|
||||||
j / k replace preview with the selected entry
|
j / k replace preview with the selected entry
|
||||||
<CR>, o, v, t open the file and close the preview
|
<CR>, o, v, t open the file and close the preview
|
||||||
:pclose / <C-w>z close the preview and stop live updates
|
:pclose / <C-w>z close the preview and stop live updates
|
||||||
|
|
@ -672,6 +672,7 @@ file 3.2K 2026-10-27 12:55 telescope.lua
|
||||||
- [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
|
- [x] Add count-aware `<M-j>` / `<M-k>` preview scrolling without moving focus from netrw
|
||||||
- [x] Make preview scrolling silently clamp at file/window boundaries
|
- [x] Make preview scrolling silently clamp at file/window boundaries
|
||||||
|
- [x] Make `p` toggle an existing preview closed as well as opening it
|
||||||
- [ ] 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
|
||||||
|
|
||||||
|
|
|
||||||
10
README.md
10
README.md
|
|
@ -99,7 +99,7 @@ Core keymaps available globally (not plugin-specific). These provide fallbacks f
|
||||||
|
|
||||||
| Key | Description |
|
| Key | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `p` | Preview the selected file or directory below and enable live cursor updates |
|
| `p` | Toggle the selected file/directory preview and 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 |
|
| `<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 |
|
||||||
|
|
@ -120,10 +120,10 @@ Preview-only file buffers remain loaded but unlisted until Neovim exits, avoidin
|
||||||
the parser detachment that triggers this Neovim 0.12 race.
|
the parser detachment that triggers this Neovim 0.12 race.
|
||||||
|
|
||||||
Opening a file with `<CR>`, `o`, `v`, or `t`, or otherwise leaving netrw, closes
|
Opening a file with `<CR>`, `o`, `v`, or `t`, or otherwise leaving netrw, closes
|
||||||
the preview. Closing it manually also disables live updates until `p` is pressed
|
the preview. Closing it manually or pressing `p` again disables live updates
|
||||||
again. Enhanced directory summaries apply to local paths (including local paths
|
until `p` is pressed again. Enhanced directory summaries apply to local paths
|
||||||
when Neovim runs over SSH); netrw URI browsing retains its native preview
|
(including local paths when Neovim runs over SSH); netrw URI browsing retains
|
||||||
behavior.
|
its native preview behavior.
|
||||||
|
|
||||||
##### File Operations
|
##### File Operations
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -657,10 +657,17 @@ function M.setup(buf)
|
||||||
vim.keymap.set('n', 'p', function()
|
vim.keymap.set('n', 'p', function()
|
||||||
state.win = vim.api.nvim_get_current_win()
|
state.win = vim.api.nvim_get_current_win()
|
||||||
state.tab = vim.api.nvim_get_current_tabpage()
|
state.tab = vim.api.nvim_get_current_tabpage()
|
||||||
|
|
||||||
|
if find_preview_window(state.tab) then
|
||||||
|
close_timer(state)
|
||||||
|
close_preview(state)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
preview_selected(state, true)
|
preview_selected(state, true)
|
||||||
end, {
|
end, {
|
||||||
buffer = buf,
|
buffer = buf,
|
||||||
desc = 'Netrw: Preview selection and enable live updates',
|
desc = 'Netrw: Toggle preview and live updates',
|
||||||
nowait = true,
|
nowait = true,
|
||||||
silent = true,
|
silent = true,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue