Neovim plugin improving access to clipboard history (mirror)
at main 41 lines 975 B view raw
1local M = {} 2 3local state = require("yankbank.state") 4local persistence = {} 5 6---add entry from bank to 7---@param entry string 8---@param reg_type string 9---@param pin integer|boolean? 10function M.add_entry(entry, reg_type, pin) 11 local opts = state.get_opts() 12 if opts.persist_type == "sqlite" then 13 persistence:insert_yank(entry, reg_type, pin) 14 end 15end 16 17--- get current state of yanks in persistent storage 18function M.get_yanks() 19 local opts = state.get_opts() 20 if opts.persist_type == "sqlite" then 21 return persistence:get_bank() 22 end 23end 24 25---initialize bank persistence 26---@return table 27---@return table 28---@return table 29function M.setup() 30 local opts = state.get_opts() 31 if not opts.persist_type then 32 return {}, {}, {} 33 elseif opts.persist_type == "sqlite" then 34 persistence = require("yankbank.persistence.sql").setup() 35 return persistence:get_bank() 36 else 37 return {}, {}, {} 38 end 39end 40 41return M