Refactor previewers (#345)

This commit is contained in:
Simon Hauser
2020-12-19 16:45:02 +01:00
committed by GitHub
parent 7950fc8ba0
commit 8c90d4855c
5 changed files with 440 additions and 399 deletions

View File

@@ -0,0 +1,17 @@
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