-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpeekstack.txt
More file actions
466 lines (391 loc) · 16.7 KB
/
peekstack.txt
File metadata and controls
466 lines (391 loc) · 16.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
*peekstack.txt* Exploration-first peek stack
peekstack.nvim
==============================================================================
INTRODUCTION *peekstack*
peekstack.nvim provides a peek stack UI for LSP, diagnostics, files, marks,
and grep results. Pop open floating windows that stack visually, navigate
between them, promote to splits, and optionally persist sessions.
Requires Neovim >= 0.10.
==============================================================================
SETUP *peekstack-setup*
Call `setup()` in your Neovim configuration to enable the plugin:
>lua
require("peekstack").setup()
<
With options:
>lua
require("peekstack").setup({
ui = {
layout = {
style = "stack", -- "stack" | "cascade" | "single"
offset = { row = 1, col = 4 }, -- Cascade offset per popup
shrink = { w = 4, h = 2 }, -- Shrink per cascade level
min_size = { w = 60, h = 12 }, -- Minimum popup dimensions
max_ratio = 0.65, -- Max ratio of editor size
zindex_base = 50, -- Base z-index for popups
},
title = {
enabled = true,
format = "{icon}{kind}{provider} {path}:{line}{context}",
icons = {
enabled = true,
map = {
lsp = " ",
diagnostics = " ",
grep = " ",
file = " ",
marks = " ",
},
},
context = {
enabled = false,
max_depth = 5,
separator = " • ",
node_types = {},
},
},
path = {
base = "repo", -- "repo" | "cwd" | "absolute"
max_width = 80,
},
stack_view = {
position = "right", -- "left" | "right" | "bottom"
},
inline_preview = {
enabled = true,
max_lines = 10,
hl_group = "PeekstackInlinePreview",
close_events = { "CursorMoved", "InsertEnter", "BufLeave", "WinLeave" },
},
quick_peek = {
close_events = { "CursorMoved", "InsertEnter", "BufLeave", "WinLeave" },
},
popup = {
editable = false, -- Allow editing popup scratch buffers
buffer_mode = "copy", -- "copy" | "source"
source = {
prevent_auto_close_if_modified = true,
confirm_on_close = true,
},
history = {
max_items = 50,
restore_position = "top", -- "top" | "original"
},
auto_close = {
enabled = false,
idle_ms = 300000,
check_interval_ms = 60000,
ignore_pinned = true,
},
},
feedback = {
highlight_origin_on_close = true,
},
promote = {
close_popup = true, -- Close popup after promote
},
keys = {
close = "q",
focus_next = "<C-j>",
focus_prev = "<C-k>",
promote_split = "<C-x>",
promote_vsplit = "<C-v>",
promote_tab = "<C-t>",
toggle_stack_view = "<leader>os",
},
},
picker = {
backend = "builtin", -- "builtin" | "telescope" | "fzf-lua" | "snacks"
builtin = {
preview_lines = 1,
},
},
providers = {
lsp = { enable = true },
diagnostics = { enable = true },
file = { enable = true },
marks = {
enable = false,
scope = "all", -- "buffer" | "global" | "all"
include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
include_special = false,
},
},
persist = {
enabled = false,
max_items = 200,
session = {
default_name = "default",
prompt_if_missing = true,
},
auto = {
enabled = false,
session_name = "auto",
restore = true,
save = true,
restore_if_empty = true,
debounce_ms = 1000,
save_on_leave = true,
},
},
})
<
==============================================================================
PICKER *peekstack-picker*
Peekstack opens a picker when multiple locations are returned (e.g. references).
Configure the backend with `picker.backend`:
builtin (default)
telescope (requires nvim-telescope/telescope.nvim)
fzf-lua (requires ibhagwan/fzf-lua)
snacks (requires folke/snacks.nvim)
>lua
require("peekstack").setup({
picker = { backend = "telescope" },
})
<
For external backends (`telescope`, `fzf-lua`, `snacks`), picker preview windows
show file content around the selected location.
Picker labels use a unified readable format:
<text> - <path>:<line>:<col>
or, when text is empty:
<path>:<line>:<col>
If the chosen plugin is not installed, a warning is shown and the picker will not open.
==============================================================================
COMMANDS *peekstack-cmds*
Commands are registered after `setup()` is called.
:PeekstackStack *:PeekstackStack*
Open the stack view panel listing all active popups.
Position is configurable via `ui.stack_view.position`
(`left` / `right` / `bottom`).
The focused popup is highlighted with a `▶` marker.
Tree guides are shown for nested popup depth:
`├` / `└` for sibling relation under the same parent.
`│` is shown only when an ancestor branch continues.
No guide for root-level popups or when parent is not visible.
Each entry shows a preview line of the source code below it.
Preview lines use Tree-sitter based syntax highlights when available.
:PeekstackSaveSession *:PeekstackSaveSession*
Save the current popup stack to disk (requires persist.enabled = true).
:PeekstackRestoreSession *:PeekstackRestoreSession*
Restore a previously saved session from disk.
:PeekstackListSessions *:PeekstackListSessions*
List all saved sessions. Select one to view its summary.
:PeekstackDeleteSession {name} *:PeekstackDeleteSession*
Delete a saved session by name. Prompts for confirmation.
:PeekstackRestorePopup *:PeekstackRestorePopup*
Restore the last closed popup from history (undo close).
:PeekstackRestoreAllPopups *:PeekstackRestoreAllPopups*
Restore all closed popups from history.
:PeekstackCloseAll *:PeekstackCloseAll*
Close all popups in the current stack.
:PeekstackHistory *:PeekstackHistory*
Show popup history and select an entry to restore.
:PeekstackQuickPeek *:PeekstackQuickPeek*
Quick peek without adding to the stack. Takes an optional provider name
(default: "lsp.definition"). Any registered provider can be used.
==============================================================================
PROVIDERS *peekstack-providers*
Built-in providers are enabled via `providers.*.enable` in setup
(grep is always available; requires rg).
LSP:
lsp.definition
lsp.implementation
lsp.references
lsp.type_definition
lsp.declaration
lsp.symbols_document
Diagnostics:
diagnostics.under_cursor diagnostics at the cursor line (message shown above the preview)
diagnostics.in_buffer all diagnostics in the current buffer
File:
file.under_cursor file path under cursor
Grep (requires rg):
grep.search prompts for a ripgrep query
Marks (requires providers.marks.enable = true):
marks.buffer buffer-local marks
marks.global global marks
marks.all buffer + global marks
Filter with providers.marks.include / include_special.
Scope is selected by the provider name.
==============================================================================
API *peekstack-api*
The main module exposes the following API:
`require("peekstack").setup(opts)`
Initialize the plugin with the given options.
`require("peekstack").peek(provider, opts)` *peek()*
Peek by provider name. Example:
>lua
require("peekstack").peek("lsp.definition")
<
opts.mode can be:
- "inline": show an inline preview without stacking
- "quick": temporary popup that does not join the stack
`require("peekstack").peek.definition(opts)`
`require("peekstack").peek.implementation(opts)`
`require("peekstack").peek.references(opts)`
`require("peekstack").peek.type_definition(opts)`
`require("peekstack").peek.declaration(opts)`
`require("peekstack").peek.symbols_document(opts)`
`require("peekstack").peek.diagnostics_cursor(opts)`
`require("peekstack").peek.diagnostics_buffer(opts)`
`require("peekstack").peek.file_under_cursor(opts)`
`require("peekstack").peek.grep(opts)`
`require("peekstack").peek.marks_buffer(opts)`
`require("peekstack").peek.marks_global(opts)`
`require("peekstack").peek.marks_all(opts)`
Convenience shortcuts for built-in providers.
Built-in provider names:
lsp.definition
lsp.implementation
lsp.references
lsp.type_definition
lsp.declaration
lsp.symbols_document
diagnostics.under_cursor
diagnostics.in_buffer
file.under_cursor
grep.search
marks.buffer
marks.global
marks.all
(marks require their provider enabled; grep.search requires rg)
`require("peekstack").peek_location(loc, opts)`
Peek a single normalized location.
`require("peekstack").peek_locations(locations, opts)`
Peek multiple locations (uses picker if more than one).
`require("peekstack").register_provider(name, fn)`
Register a custom location provider.
>lua
require("peekstack").register_provider("my.provider", function(cb)
cb({ { uri = "file:///path", range = { ... } } })
end)
<
`require("peekstack").register_picker(name, mod)`
Register a custom picker backend.
The module must implement `pick(locations, opts, cb)` and call `cb` with the
chosen location (or nil to cancel).
`require("peekstack").stack`
Proxy to the stack module. Key functions:
- `.push(location, opts)` - Push a popup onto the stack
- `.close(id, winid)` - Close a popup by id
- `.close_all(winid)` - Close all popups in a stack
- `.focus_next()` / `.focus_prev()` - Navigate popups
- `.list(winid)` - List all popups in a stack
`require("peekstack").persist`
Proxy to the persist module:
- `.save_current()` - Save the current session
- `.restore()` - Restore a saved session
- `.list_sessions()` - List saved sessions
- `.delete_session(name)` - Delete a session
- `.rename_session(from, to)` - Rename a session
==============================================================================
PERSIST *peekstack-persist*
Persistence is disabled by default. Enable with `persist.enabled = true`.
Persistence scope is fixed to the current git repository ("repo").
`persist.session.default_name` is used when a name is omitted, unless
`persist.session.prompt_if_missing` is true.
Auto persistence (`persist.auto`) requires `persist.enabled = true`:
enabled enable auto save/restore
session_name session name for auto mode (default: "auto")
restore restore on VimEnter / DirChanged
restore_if_empty only restore when the stack is empty
save save on PeekstackPush/Close/RestorePopup (debounced)
debounce_ms debounce time for auto save
save_on_leave save on VimLeavePre
Auto persistence runs only inside a git repository and uses scope "repo".
==============================================================================
BUFFER MODES *peekstack-buffer-modes*
`ui.popup.buffer_mode` controls how popup buffers are created:
"copy" (default) scratch buffer with copied lines
editing is controlled by `ui.popup.editable`
"source" use the real source buffer (useful for editing)
`ui.popup.source.confirm_on_close` prompts on close if modified
`ui.popup.source.prevent_auto_close_if_modified` blocks auto-close
==============================================================================
STACK VIEW *peekstack-stack-view*
`ui.stack_view.position` controls where the stack view panel opens:
"right" (default) right-side panel
"left" left-side panel
"bottom" bottom panel across full editor width
==============================================================================
EVENTS *peekstack-events*
peekstack emits `User` autocmds for integration.
Popup events:
PeekstackPush
PeekstackClose
PeekstackFocus
PeekstackHistoryPush
PeekstackRestorePopup
PeekstackPromote
Persist events:
PeekstackSave
PeekstackRestore
PeekstackDeleteSession
PeekstackRenameSession
Event data keys (vary per event):
event, popup_id, winid, bufnr, root_winid, provider, location
session, item_count, from, to, action, ephemeral
==============================================================================
KEYMAPS *peekstack-keymaps*
Default keymaps inside popup windows:
`q` Close the current popup
`<C-j>` Focus the next popup in the stack
`<C-k>` Focus the previous popup in the stack
`<C-x>` Promote to horizontal split
`<C-v>` Promote to vertical split
`<C-t>` Promote to new tab
`<leader>os` Toggle the stack view panel
Stack view keymaps:
`<CR>` Focus the selected popup
`dd` Close the selected popup
`u` Undo close (restore last closed popup)
`U` Restore all closed popups
`H` Show history list (select to restore)
`r` Rename the selected popup
`p` Toggle pin (skip auto-close)
`/` Filter the list
`gg/G` Jump to first/last stack item
`j/k` Move cursor by stack item (skip header/preview lines)
`?` Toggle help
`q` Close the stack view
Stack view tree guides:
`├` / `└` Sibling relation under the same parent
`│` Ancestor branch that still has later siblings
no guide Root-level popup or parent not visible
==============================================================================
HIGHLIGHT GROUPS *peekstack-highlights*
Title highlights:
PeekstackTitleProvider Provider name (links to Type)
PeekstackTitlePath File path (links to Directory)
PeekstackTitleIcon Provider icon (links to Special)
PeekstackTitleLine Line number (links to LineNr)
PeekstackTitleKindError Diagnostic error severity (links to DiagnosticError)
PeekstackTitleKindWarn Diagnostic warn severity (links to DiagnosticWarn)
PeekstackTitleKindInfo Diagnostic info severity (links to DiagnosticInfo)
PeekstackTitleKindHint Diagnostic hint severity (links to DiagnosticHint)
Popup border highlights:
PeekstackPopupBorder Unfocused popup border (links to FloatBorder)
PeekstackPopupBorderFocused Focused popup border (links to Function)
Stack view highlights:
PeekstackStackViewIndex Entry index number (links to LineNr)
PeekstackStackViewPinned Pin badge (links to DiagnosticWarn)
PeekstackStackViewProvider Provider name (links to Type)
PeekstackStackViewPath File path (links to Directory)
PeekstackStackViewIcon Provider icon (links to Special)
PeekstackStackViewLine Line number (links to LineNr)
PeekstackStackViewFocused Focused entry marker (links to Type)
PeekstackStackViewPreview Preview line base text (links to Comment)
PeekstackStackViewFilter Filter header (links to Search)
PeekstackStackViewHeader Stack header (links to Title)
PeekstackStackViewEmpty Empty state text (links to Comment)
PeekstackStackViewCursorLine Cursor line (links to CursorLine)
Other highlights:
PeekstackOrigin Origin highlight flash (links to IncSearch)
PeekstackInlinePreview Inline preview text (links to Comment)
==============================================================================
HEALTH *peekstack-health*
Run `:checkhealth peekstack` to verify requirements:
- Neovim >= 0.10
- `rg` executable (optional, for grep.search)
==============================================================================
vim:tw=78:ts=8:ft=help:norl: