@@ -27,8 +27,11 @@ function Previewer.base:new(o, opts, fzf_win)
27
27
self .win = fzf_win
28
28
self .delay = self .win .winopts .preview .delay or 100
29
29
self .title = self .win .winopts .preview .title
30
- self .title_fnamemodify = o .title_fnamemodify
31
30
self .title_pos = self .win .winopts .preview .title_pos
31
+ self .title_fnamemodify = o .title_fnamemodify
32
+ self .render_markdown = o .render_markdown
33
+ self .render_markdown .filetypes = type (o .render_markdown .filetypes ) == " table" and
34
+ o .render_markdown .filetypes or {}
32
35
self .winopts = self .win .winopts .preview .winopts
33
36
self .syntax = default (o .syntax , true )
34
37
self .syntax_delay = tonumber (default (o .syntax_delay , 0 ))
@@ -404,6 +407,7 @@ function Previewer.base:scroll(direction)
404
407
vim .wo [preview_winid ].cursorline = false
405
408
end
406
409
end
410
+ self :update_render_markdown ()
407
411
self .win :update_scrollbar ()
408
412
end
409
413
@@ -650,7 +654,8 @@ function Previewer.buffer_or_file:populate_preview_buf(entry_str)
650
654
-- in case of an error display the stacktrace in the preview buffer
651
655
local lines = vim .split (res , " \n " ) or { " null" }
652
656
table.insert (lines , 1 ,
653
- string.format (" lsp.util.%s failed for '%s':" , utils .__HAS_NVIM_011 and " show_document" or " jump_to_location" , entry .uri ))
657
+ string.format (" lsp.util.%s failed for '%s':" ,
658
+ utils .__HAS_NVIM_011 and " show_document" or " jump_to_location" , entry .uri ))
654
659
table.insert (lines , 2 , " " )
655
660
local tmpbuf = self :get_tmp_buffer ()
656
661
vim .api .nvim_buf_set_lines (tmpbuf , 0 , - 1 , false , lines )
@@ -766,6 +771,20 @@ local ts_attach = function(bufnr, ft)
766
771
end
767
772
end
768
773
774
+ function Previewer .base :update_render_markdown (ft )
775
+ local bufnr , winid = self .preview_bufnr , self .win .preview_winid
776
+ ft = ft or vim .bo [bufnr ].ft
777
+ if not ft then return end
778
+ if not package.loaded [" render-markdown" ]
779
+ or not self .render_markdown .enable
780
+ or not self .render_markdown .filetypes [ft ]
781
+ then
782
+ return
783
+ end
784
+ vim .bo [bufnr ].ft = ft
785
+ require (" render-markdown.core.ui" ).update (bufnr , winid , " FzfLua" , true )
786
+ end
787
+
769
788
function Previewer .buffer_or_file :do_syntax (entry )
770
789
if not self .preview_bufnr then return end
771
790
if not entry or not entry .path then return end
@@ -829,6 +848,8 @@ function Previewer.buffer_or_file:do_syntax(entry)
829
848
end
830
849
if not ts_enabled or not ts_success then
831
850
pcall (function () vim .bo [bufnr ].syntax = ft end )
851
+ elseif ts_enabled and ts_success then
852
+ self :update_render_markdown (ft )
832
853
end
833
854
end )()
834
855
end
0 commit comments