···115115| persist_type | string defining persistence type "sqlite" or nil | `nil` |
116116| db_path | string defining database file path for use with sqlite persistence | plugin install directory |
117117| bind_indices | optional string to be used for keybind prefix for pasting by index number (i.e. "<leader>p") | `nil` |
118118+| pickers | table containing all pickers. | `{}` |
119119+| pickers.snacks | boolean | `false` |
118120119121120122#### Example Configuration
···122124```lua
123125{
124126 "ptdewey/yankbank-nvim",
127127+ dependencies = {
128128+ "folke/snacks.nvim", -- (optional) - snacks picker integration
129129+ },
125130 config = function()
126131 require('yankbank').setup({
127132 max_entries = 9,
···137142 yank_register = "+",
138143 },
139144 bind_indices = "<leader>p"
145145+ pickers = {
146146+ snacks = true,
147147+ },
140148 })
141149 end,
142150}
···187195-- map to '<leader>y'
188196vim.keymap.set("n", "<leader>y", "<cmd>YankBank<CR>", { noremap = true })
189197```
198198+199199+### Snacks Picker
200200+If `pickers.snacks` is set to true in the setup options, the snacks picker can be used to open the yankbank menu.
201201+This can be triggered by running the command `:YankBankSnacks` or using `Snacks.picker.yankbank()` as you would any other snacks picker.
190202191203---
192204
+5-1
lua/yankbank/init.lua
···1313 -- enable persistence based on opts (needs to be called before autocmd setup)
1414 local yanks, reg_types, pins = persistence.setup()
1515 state.init(yanks, reg_types, pins, state.get_opts())
1616-1716 initialized = true
1817end
1918···6059 persist_type = nil,
6160 db_path = nil,
6261 bind_indices = nil,
6262+ pickers = {},
6363 }
64646565 -- merge opts with default options table
···9393 desc = "Paste YankBank entry " .. i,
9494 })
9595 end
9696+ end
9797+9898+ if merged_opts.pickers.snacks then
9999+ require("yankbank.pickers.snacks").setup()
96100 end
97101end
98102
+57
lua/yankbank/pickers/snacks.lua
···11+-- luacheck: globals Snacks
22+local M = {}
33+44+---@type snacks.picker.Config
55+local snacks_source = {
66+ title = "YankBank",
77+ finder = function()
88+ local yanks = require("yankbank.api").get_all()
99+ local items = {}
1010+ for i = 1, #yanks do
1111+ local yank = yanks[i]
1212+ local yank_text = yank.yank_text
1313+ table.insert(items, {
1414+ label = tostring(i),
1515+ reg = tostring(i),
1616+ -- This is not used right now, but might be useful in the future
1717+ -- to determine how to paste the content
1818+ reg_type = yank.reg_type,
1919+ -- data is used as the paste content
2020+ data = yank_text,
2121+ -- text is used by the matcher for searching
2222+ text = yank_text,
2323+ -- value is used to display in the picker
2424+ value = yank_text,
2525+ preview = {
2626+ text = yank_text,
2727+ -- Currently this is pinned to the current buffer's filetype
2828+ -- as we don't store the filetype of each yank.
2929+ -- This should be sufficient, as you would usually want to
3030+ -- paste into the same filetype you yanked from.
3131+ ft = vim.bo.filetype,
3232+ },
3333+ })
3434+ end
3535+ return items
3636+ end,
3737+ format = "register",
3838+ preview = "preview",
3939+ confirm = { "paste", "close" },
4040+}
4141+4242+function M.setup()
4343+ if Snacks and Snacks.picker then
4444+ Snacks.picker.sources.yankbank = snacks_source
4545+ end
4646+ vim.api.nvim_create_user_command("YankBankSnacks", function()
4747+ if Snacks then
4848+ Snacks.picker(snacks_source)
4949+ else
5050+ vim.notify("Yank bank: Snacks is not loaded", vim.log.levels.ERROR)
5151+ end
5252+ end, {
5353+ desc = "Open yankbank in snacks picker",
5454+ })
5555+end
5656+5757+return M