diff options
| author | Simon Hauser <Simon-Hauser@outlook.de> | 2020-11-22 03:33:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-21 21:33:27 -0500 |
| commit | d153c006e76db4d56eeb03605698a23344cfadbd (patch) | |
| tree | 5733881aad9b86dcb2b961b8ff7d8ac5c36f4413 /lua/telescope/previewers.lua | |
| parent | 5bf53823eb7bff7031368dbfa659f0b9775b89e7 (diff) | |
feat: Add highlights builtin (#267)
Diffstat (limited to 'lua/telescope/previewers.lua')
| -rw-r--r-- | lua/telescope/previewers.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lua/telescope/previewers.lua b/lua/telescope/previewers.lua index 705b73d..9898079 100644 --- a/lua/telescope/previewers.lua +++ b/lua/telescope/previewers.lua @@ -680,6 +680,30 @@ previewers.man = defaulter(function(_) } end) +previewers.display_content = defaulter(function(_) + return previewers.new { + preview_fn = function(self, entry, status) + with_preview_window(status, nil, function() + local bufnr = vim.fn.bufadd("Preview command") + vim.api.nvim_win_set_buf(status.preview_win, bufnr) + vim.api.nvim_win_set_option(status.preview_win, 'wrap', true) + vim.api.nvim_win_set_option(status.preview_win, 'winhl', 'Normal:Normal') + vim.api.nvim_win_set_option(status.preview_win, 'signcolumn', 'no') + vim.api.nvim_win_set_option(status.preview_win, 'foldlevel', 100) + + if type(entry.preview_command) ~= 'function' then + print('entry must provide a preview_command function which will put the content into the buffer') + return + end + + entry.preview_command(entry, bufnr) + + self.state.hl_win = status.preview_win + end) + end + } +end, {}) + previewers.Previewer = Previewer return previewers |
