···2121---@param pin integer|boolean?
2222function M.add_yank(text, reg_type, pin)
2323 -- avoid adding empty strings
2424- if text == "" and text == " " and text == "\n" then
2424+ if text == "" or text == " " or text == "\n" then
2525 return
2626 end
2727···53535454 -- trim table size if necessary
5555 local opts = state.get_opts()
5656- if #yanks > opts.max_entries then
5656+ local max_entries = opts.max_entries or 10
5757+ if #yanks > max_entries then
5758 local i = last_zero_entry(pins)
58595960 if not i or i == 1 then
+55
lua/yankbank/health.lua
···11+local M = {}
22+33+local start = vim.health.start or vim.health.report_start
44+local ok = vim.health.ok or vim.health.report_ok
55+local warn = vim.health.warn or vim.health.report_warn
66+local err = vim.health.error or vim.health.report_error
77+local info = vim.health.info or vim.health.report_info
88+99+function M.check()
1010+ start("yankbank")
1111+1212+ if vim.fn.has("nvim-0.10") == 1 then
1313+ ok("nvim 0.10+ detected")
1414+ else
1515+ err("yankbank requires nvim 0.10 or newer")
1616+ end
1717+1818+ local state = require("yankbank.state")
1919+ local opts = state.get_opts()
2020+ if opts and next(opts) ~= nil then
2121+ ok("setup() has been called")
2222+ info("max_entries = " .. tostring(opts.max_entries))
2323+ info("yank_register = " .. tostring(opts.registers and opts.registers.yank_register))
2424+ info("persist_type = " .. tostring(opts.persist_type))
2525+ else
2626+ warn("setup() has not been called — defaults will apply on first yank")
2727+ end
2828+2929+ local clipboard = vim.fn.has("clipboard") == 1
3030+ if clipboard then
3131+ ok("clipboard provider available")
3232+ else
3333+ warn("no clipboard provider detected — `+` register yanks will not be captured")
3434+ end
3535+3636+ if opts and opts.persist_type == "sqlite" then
3737+ local has_sqlite = pcall(require, "sqlite")
3838+ if has_sqlite then
3939+ ok("sqlite.lua is installed")
4040+ else
4141+ err("persist_type = 'sqlite' but sqlite.lua is not installed")
4242+ end
4343+ end
4444+4545+ if opts and opts.pickers and opts.pickers.snacks then
4646+ local has_snacks = pcall(require, "snacks")
4747+ if has_snacks then
4848+ ok("snacks.nvim is installed")
4949+ else
5050+ err("pickers.snacks is enabled but snacks.nvim is not installed")
5151+ end
5252+ end
5353+end
5454+5555+return M
+1-1
lua/yankbank/init.lua
···12121313 -- 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())
1515+ state.init(yanks, reg_types, pins)
1616 initialized = true
1717end
1818
+1-2
lua/yankbank/state.lua
···3939 state.opts = opts
4040end
41414242-function M.init(yanks, reg_types, pins, opts)
4242+function M.init(yanks, reg_types, pins)
4343 state.yanks = yanks or {}
4444 state.reg_types = reg_types or {}
4545 state.pins = pins or {}
4646- state.opts = opts or {}
4746end
48474948return M