diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-08-31 00:06:33 -0400 |
|---|---|---|
| committer | TJ DeVries <devries.timothyj@gmail.com> | 2020-08-31 00:06:53 -0400 |
| commit | 6b066cf9e866729b9c8292d7ab3e8071abdd7d45 (patch) | |
| tree | 20049f31c35f46d18607d65cbaec3139d7c02f75 /lua/telescope/previewers.lua | |
| parent | a6fe9721ac0791bdf18a04594c31b28e879ed63e (diff) | |
feat: Add better mapping support
Diffstat (limited to 'lua/telescope/previewers.lua')
| -rw-r--r-- | lua/telescope/previewers.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lua/telescope/previewers.lua b/lua/telescope/previewers.lua index 3e79ad3..4743639 100644 --- a/lua/telescope/previewers.lua +++ b/lua/telescope/previewers.lua @@ -34,6 +34,27 @@ previewers.new = function(...) return Previewer:new(...) end +previewers.new_termopen = function(opts) + local entry_value = opts.get_value or function(entry) + return entry.value + end + + local command_string = opts.command + + return previewers.new { + preview_fn = function(_, entry, status) + local bufnr = vim.api.nvim_create_buf(false, true) + + vim.api.nvim_win_set_buf(status.preview_win, bufnr) + + -- HACK! Requires `termopen` to accept buffer argument. + vim.cmd(string.format("noautocmd call win_gotoid(%s)", status.preview_win)) + vim.fn.termopen(string.format(command_string, entry_value(entry))) + vim.cmd(string.format("noautocmd call win_gotoid(%s)", status.prompt_win)) + end + } +end + previewers.vim_buffer = previewers.new { preview_fn = function(_, entry, status) local value = entry.value |
