minimal extui fuzzy finder for neovim

feat: use `artio.schedule(f)` api fn

+24 -15
+1 -12
lua/artio/builtins.lua
··· 28 28 return 29 29 end 30 30 31 - local Picker = require("artio.picker") 32 - local current = Picker.active_picker 33 - if not current or not current.closed then 34 - return 35 - end 36 - 37 - vim.schedule(function() 38 - vim.defer_fn(builtins[fname], 10) 39 - vim.wait(1000, function() 40 - return coroutine.status(current.co) == "dead" 41 - end) 42 - end) 31 + artio.schedule(builtins[fname]) 43 32 end, 44 33 }, props) 45 34 )
+23 -3
lua/artio/init.lua
··· 132 132 "force", 133 133 { 134 134 on_close = function(_, idx) 135 - return on_choice(items[idx], idx) 135 + artio.schedule(function() 136 + on_choice(items[idx], idx) 137 + end) 136 138 end, 137 139 on_quit = function() 138 - return on_choice(nil, nil) 140 + artio.schedule(function() 141 + on_choice(nil, nil) 142 + end) 139 143 end, 140 144 }, 141 145 opts or {}, -- opts.prompt, opts.format_item ··· 160 164 return Picker:new(...):open() 161 165 end 162 166 167 + ---@param f fun(): any 168 + artio.schedule = function(f) 169 + local Picker = require("artio.picker") 170 + local current = Picker.active_picker 171 + if not current or not current.closed then 172 + return 173 + end 174 + 175 + vim.schedule(function() 176 + vim.defer_fn(f, 10) 177 + vim.wait(1000, function() 178 + return coroutine.status(current.co) == "dead" 179 + end) 180 + end) 181 + end 182 + 163 183 ---@param fn artio.Picker.action 164 184 ---@param scheduled_fn? artio.Picker.action 165 185 artio.wrap = function(fn, scheduled_fn) ··· 180 200 if scheduled_fn == nil then 181 201 return 182 202 end 183 - vim.schedule(function() 203 + artio.schedule(function() 184 204 pcall(scheduled_fn, current) 185 205 end) 186 206 end