From c067c082114a31e87bb22202e626441bb36fc4f2 Mon Sep 17 00:00:00 2001 From: Diogo Duarte Date: Thu, 22 Feb 2024 10:31:39 +0000 Subject: [PATCH] Update to new plugin API --- init.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index ce7cdef..1b271f0 100644 --- a/init.lua +++ b/init.lua @@ -14,7 +14,7 @@ local SUPPORTED_KEYS = { { on = "u"}, { on = "v"}, { on = "w"}, { on = "x"}, { on = "y"}, { on = "z"}, } -local save_bookmark = ya.sync(function(idx) +local save_bookmark = ya.sync(function(state, idx) local folder = Folder:by_kind(Folder.CURRENT) state.bookmarks = state.bookmarks or {} @@ -25,11 +25,17 @@ local save_bookmark = ya.sync(function(idx) } end) -local all_bookmarks = ya.sync(function() return state.bookmarks or {} end) +local all_bookmarks = ya.sync(function(state) + return state.bookmarks or {} +end) -local delete_bookmark = ya.sync(function(idx) table.remove(state.bookmarks, idx) end) +local delete_bookmark = ya.sync(function(state, idx) + table.remove(state.bookmarks, idx) +end) -local delete_all_bookmarks = ya.sync(function() state.bookmarks = nil end) +local delete_all_bookmarks = ya.sync(function(state) + state.bookmarks = nil +end) return { entry = function(_, args) @@ -39,7 +45,7 @@ return { end if action == "save" then - local key = ya.which { cands = SUPPORTED_KEYS, silent = true } + local key = ya.which({ cands = SUPPORTED_KEYS, silent = true }) if key then save_bookmark(key) end @@ -51,7 +57,7 @@ return { end local bookmarks = all_bookmarks() - local selected = #bookmarks > 0 and ya.which { cands = bookmarks } + local selected = #bookmarks > 0 and ya.which({ cands = bookmarks }) if not selected then return end