Skip to content

Commit 8dbfe52

Browse files
committed
docs(extensions): add extensions section to README and vimdoc
1 parent 7a93d6f commit 8dbfe52

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,25 @@ Candidate labels are shown in a readable unified format:
291291

292292
If the chosen plugin is not installed, a warning is shown and the picker will not open.
293293

294+
## 🔌 Extensions (push from external pickers)
295+
296+
Push results from external pickers (telescope / fzf-lua / snacks.nvim) directly
297+
onto the peekstack stack. Each extension provides `push_file`, `push_grep`,
298+
`push_lsp_references`, and a generic `actions.push` for custom configurations.
299+
300+
```lua
301+
-- snacks.nvim
302+
vim.keymap.set("n", "<leader>pf", require("peekstack.extensions.snacks").push_file)
303+
304+
-- fzf-lua
305+
vim.keymap.set("n", "<leader>pf", require("peekstack.extensions.fzf_lua").push_file)
306+
307+
-- telescope
308+
vim.keymap.set("n", "<leader>pf", "<cmd>Telescope peekstack push_file<cr>")
309+
```
310+
311+
See `:help peekstack-extensions` for the full API and custom action examples.
312+
294313
## 💾 Persist sessions
295314

296315
When `persist.enabled = true`, `PeekstackSaveSession` uses `persist.session.default_name`

doc/peekstack.txt

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,97 @@ or, when text is empty:
162162

163163
If the chosen plugin is not installed, a warning is shown and the picker will not open.
164164

165+
==============================================================================
166+
EXTENSIONS *peekstack-extensions*
167+
168+
Extensions push results from external picker plugins onto the peekstack stack.
169+
Unlike picker backends (which peekstack opens internally), extensions hook into
170+
your picker workflow so selected items become peekstack popups.
171+
172+
Supported pickers: telescope, fzf-lua, snacks.nvim.
173+
174+
Each extension provides:
175+
`push_file(opts)` Open file picker → push to stack
176+
`push_grep(opts)` Open grep picker → push to stack
177+
`push_lsp_references(opts)` Open LSP references picker → push to stack
178+
`actions.push` Generic action for custom picker configs
179+
180+
SNACKS.NVIM ~
181+
*peekstack-extensions-snacks*
182+
>lua
183+
local snacks = require("peekstack.extensions.snacks")
184+
vim.keymap.set("n", "<leader>pf", snacks.push_file)
185+
vim.keymap.set("n", "<leader>pg", snacks.push_grep)
186+
vim.keymap.set("n", "<leader>pr", snacks.push_lsp_references)
187+
<
188+
189+
Custom action:
190+
>lua
191+
require("snacks.picker").grep({
192+
confirm = function(picker, item)
193+
require("peekstack.extensions.snacks").actions.push(picker, item, {
194+
provider = "my_grep",
195+
})
196+
end,
197+
})
198+
<
199+
200+
FZF-LUA ~
201+
*peekstack-extensions-fzf-lua*
202+
>lua
203+
local fzf = require("peekstack.extensions.fzf_lua")
204+
vim.keymap.set("n", "<leader>pf", fzf.push_file)
205+
vim.keymap.set("n", "<leader>pg", fzf.push_grep)
206+
vim.keymap.set("n", "<leader>pr", fzf.push_lsp_references)
207+
<
208+
209+
Custom action:
210+
>lua
211+
require("fzf-lua").live_grep({
212+
actions = {
213+
["default"] = function(selected)
214+
require("peekstack.extensions.fzf_lua").actions.push(selected, {
215+
provider = "my_grep",
216+
})
217+
end,
218+
},
219+
})
220+
<
221+
222+
TELESCOPE ~
223+
*peekstack-extensions-telescope*
224+
225+
Telescope uses the standard extension mechanism:
226+
>lua
227+
vim.keymap.set("n", "<leader>pf", "<cmd>Telescope peekstack push_file<cr>")
228+
vim.keymap.set("n", "<leader>pg", "<cmd>Telescope peekstack push_grep<cr>")
229+
vim.keymap.set("n", "<leader>pr", "<cmd>Telescope peekstack push_lsp_references<cr>")
230+
<
231+
232+
Custom action:
233+
>lua
234+
require("telescope.builtin").live_grep({
235+
attach_mappings = function(_, map)
236+
local push = require("telescope").extensions.peekstack.actions.push
237+
map("i", "<CR>", function(bufnr) push(bufnr, { provider = "my_grep" }) end)
238+
map("n", "<CR>", function(bufnr) push(bufnr, { provider = "my_grep" }) end)
239+
return true
240+
end,
241+
})
242+
<
243+
244+
GENERIC PUSH ~
245+
*peekstack-extensions-push-entry*
246+
247+
For picker-agnostic integration:
248+
>lua
249+
require("peekstack").extensions.push_entry({
250+
filename = "/path/to/file.lua",
251+
lnum = 42, -- 1-based
252+
col = 5, -- 1-based
253+
}, { provider = "my_source" })
254+
<
255+
165256
==============================================================================
166257
COMMANDS *peekstack-cmds*
167258

0 commit comments

Comments
 (0)