local context_manager = require('plenary.context_manager') local utils = {} utils.with_preview_window = function(status, bufnr, callable) if bufnr and vim.api.nvim_buf_call and false then vim.api.nvim_buf_call(bufnr, callable) else return context_manager.with(function() vim.cmd(string.format("noautocmd call nvim_set_current_win(%s)", status.preview_win)) coroutine.yield() vim.cmd(string.format("noautocmd call nvim_set_current_win(%s)", status.prompt_win)) end, callable) end end return utils