diff --git a/lua/yankbank/init.lua b/lua/yankbank/init.lua index cefc011..38237ac 100644 --- a/lua/yankbank/init.lua +++ b/lua/yankbank/init.lua @@ -24,8 +24,9 @@ local default_opts = { --- wrapper function for main plugin functionality ---@param opts table ---- TODO: read from persistent database if sql persist is set (allow multi-session sync) local function show_yank_bank(opts) + yanks = persistence.get_yanks(opts) or yanks + -- initialize buffer and populate bank local bufnr, display_lines, line_yank_map = menu.create_and_fill_buffer(yanks, reg_types, opts) diff --git a/lua/yankbank/persistence.lua b/lua/yankbank/persistence.lua index 1d23441..291e0b6 100644 --- a/lua/yankbank/persistence.lua +++ b/lua/yankbank/persistence.lua @@ -12,6 +12,14 @@ function M.add_entry(entry, reg_type, opts) end end +--- get current state of yanks in persistent storage +---@param opts table +function M.get_yanks(opts) + if opts.persist_type == "sqlite" then + return persistence:get_bank() + end +end + ---initialize bank persistence ---@param opts table ---@return table diff --git a/lua/yankbank/persistence/sql.lua b/lua/yankbank/persistence/sql.lua index 4c6edbe..6868c90 100644 --- a/lua/yankbank/persistence/sql.lua +++ b/lua/yankbank/persistence/sql.lua @@ -82,8 +82,6 @@ function data:get_bank() return yanks, reg_types end --- FIX: correctly handle multiple sessions open at once - --- set up database persistence ---@param opts table ---@return sqlite_tbl data