Neovim plugin improving access to clipboard history (mirror)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: heaalthcheck and misc fixes

+60 -5
+3 -2
lua/yankbank/clipboard.lua
··· 21 21 ---@param pin integer|boolean? 22 22 function M.add_yank(text, reg_type, pin) 23 23 -- avoid adding empty strings 24 - if text == "" and text == " " and text == "\n" then 24 + if text == "" or text == " " or text == "\n" then 25 25 return 26 26 end 27 27 ··· 53 53 54 54 -- trim table size if necessary 55 55 local opts = state.get_opts() 56 - if #yanks > opts.max_entries then 56 + local max_entries = opts.max_entries or 10 57 + if #yanks > max_entries then 57 58 local i = last_zero_entry(pins) 58 59 59 60 if not i or i == 1 then
+55
lua/yankbank/health.lua
··· 1 + local M = {} 2 + 3 + local start = vim.health.start or vim.health.report_start 4 + local ok = vim.health.ok or vim.health.report_ok 5 + local warn = vim.health.warn or vim.health.report_warn 6 + local err = vim.health.error or vim.health.report_error 7 + local info = vim.health.info or vim.health.report_info 8 + 9 + function M.check() 10 + start("yankbank") 11 + 12 + if vim.fn.has("nvim-0.10") == 1 then 13 + ok("nvim 0.10+ detected") 14 + else 15 + err("yankbank requires nvim 0.10 or newer") 16 + end 17 + 18 + local state = require("yankbank.state") 19 + local opts = state.get_opts() 20 + if opts and next(opts) ~= nil then 21 + ok("setup() has been called") 22 + info("max_entries = " .. tostring(opts.max_entries)) 23 + info("yank_register = " .. tostring(opts.registers and opts.registers.yank_register)) 24 + info("persist_type = " .. tostring(opts.persist_type)) 25 + else 26 + warn("setup() has not been called — defaults will apply on first yank") 27 + end 28 + 29 + local clipboard = vim.fn.has("clipboard") == 1 30 + if clipboard then 31 + ok("clipboard provider available") 32 + else 33 + warn("no clipboard provider detected — `+` register yanks will not be captured") 34 + end 35 + 36 + if opts and opts.persist_type == "sqlite" then 37 + local has_sqlite = pcall(require, "sqlite") 38 + if has_sqlite then 39 + ok("sqlite.lua is installed") 40 + else 41 + err("persist_type = 'sqlite' but sqlite.lua is not installed") 42 + end 43 + end 44 + 45 + if opts and opts.pickers and opts.pickers.snacks then 46 + local has_snacks = pcall(require, "snacks") 47 + if has_snacks then 48 + ok("snacks.nvim is installed") 49 + else 50 + err("pickers.snacks is enabled but snacks.nvim is not installed") 51 + end 52 + end 53 + end 54 + 55 + return M
+1 -1
lua/yankbank/init.lua
··· 12 12 13 13 -- enable persistence based on opts (needs to be called before autocmd setup) 14 14 local yanks, reg_types, pins = persistence.setup() 15 - state.init(yanks, reg_types, pins, state.get_opts()) 15 + state.init(yanks, reg_types, pins) 16 16 initialized = true 17 17 end 18 18
+1 -2
lua/yankbank/state.lua
··· 39 39 state.opts = opts 40 40 end 41 41 42 - function M.init(yanks, reg_types, pins, opts) 42 + function M.init(yanks, reg_types, pins) 43 43 state.yanks = yanks or {} 44 44 state.reg_types = reg_types or {} 45 45 state.pins = pins or {} 46 - state.opts = opts or {} 47 46 end 48 47 49 48 return M