8181
8282--- @param opts ? table<string , any>
8383function M .open (opts )
84- local messages = M .find ()
84+ local id_to_message = M .find ()
8585 opts = vim .tbl_deep_extend (" force" , opts or {}, {
8686 prompt = false ,
8787 winopts = {
@@ -92,18 +92,36 @@ function M.open(opts)
9292 title_pos = " center" ,
9393 },
9494 },
95- previewer = M .previewer (messages ),
95+ previewer = M .previewer (id_to_message ),
9696 fzf_opts = {
9797 [" --no-multi" ] = " " ,
9898 [" --with-nth" ] = " 2.." ,
9999 },
100100 actions = {
101- default = function () end ,
101+ default = function (entry_str )
102+ entry_str = entry_str [1 ]
103+
104+ local id = tonumber (entry_str :match (" ^%d+" ))
105+ local message_entry = id_to_message [id ]
106+
107+ local buf = vim .api .nvim_create_buf (false , false )
108+
109+ vim .api .nvim_set_option_value (" buftype" , " nofile" , { buf = buf })
110+ vim .api .nvim_set_option_value (" bufhidden" , " wipe" , { buf = buf })
111+
112+ vim .api .nvim_buf_set_keymap (buf , " n" , " q" , " :bd<CR>" , { silent = true , noremap = true })
113+ vim .api .nvim_buf_set_lines (buf , 0 , - 1 , false , vim .split (message_entry .ordinal , " \n " ))
114+
115+ local formatted = Format .format (message_entry .message , " fzf_preview" )
116+ formatted :render (buf , Config .ns )
117+
118+ vim .api .nvim_win_set_buf (0 , buf )
119+ end ,
102120 },
103121 })
104122 local lines = vim .tbl_map (function (entry )
105123 return entry .display
106- end , vim .tbl_values (messages ))
124+ end , vim .tbl_values (id_to_message ))
107125 return fzf .fzf_exec (lines , opts )
108126end
109127
0 commit comments