diff options
| author | smolck <46855713+smolck@users.noreply.github.com> | 2020-09-06 22:07:51 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-06 23:07:51 -0400 |
| commit | 2592586533868aede5c254f4599601bf53f699da (patch) | |
| tree | 10ceb10951dab034ce2d0f8e625f3bf1734eaf67 /lua/telescope/previewers.lua | |
| parent | 675e240383454e96f0275062b1a67f8b55cc2798 (diff) | |
View the planets (#12)
* add planets viewer builtin
* Remove print statement
* Don't use fzf & echo
* Add all planets as files and refactor accordingly
* Remove planets.lua
* add the moon
* example ofe how to do this without ls everywhere
* fix rebase and update to new style
Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
Diffstat (limited to 'lua/telescope/previewers.lua')
| -rw-r--r-- | lua/telescope/previewers.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lua/telescope/previewers.lua b/lua/telescope/previewers.lua index 493a2f6..5f9268d 100644 --- a/lua/telescope/previewers.lua +++ b/lua/telescope/previewers.lua @@ -12,6 +12,7 @@ Previewer.__index = Previewer local bat_options = " --style=grid --paging=always " local previewer_ns = vim.api.nvim_create_namespace('telescope.previewers') + -- --terminal-width=%s -- TODO: We shoudl make sure that all our terminals close all the way. @@ -317,6 +318,21 @@ previewers.help = defaulter(function(_) } end, {}) +previewers.planet_previewer = previewers.new { + preview_fn = function(self, entry, status) + local bufnr = vim.api.nvim_create_buf(false, true) + + vim.api.nvim_win_set_buf(status.preview_win, bufnr) + + local termopen_command = "bat " .. entry.value + + -- HACK! Requires `termopen` to accept buffer argument. + vim.cmd(string.format("noautocmd call win_gotoid(%s)", status.preview_win)) + vim.fn.termopen(termopen_command) + vim.cmd(string.format("noautocmd call win_gotoid(%s)", status.prompt_win)) + end +} + previewers.Previewer = Previewer return previewers |
