Skip to content

Commit

Permalink
feat(fzf-lua): open the notification message from fzf
Browse files Browse the repository at this point in the history
  • Loading branch information
sufftea committed Jan 16, 2025
1 parent eaed6cc commit 5dece46
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lua/noice/integrations/fzf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ end

---@param opts? table<string, any>
function M.open(opts)
local messages = M.find()
local id_to_message = M.find()
opts = vim.tbl_deep_extend("force", opts or {}, {
prompt = false,
winopts = {
Expand All @@ -92,18 +92,36 @@ function M.open(opts)
title_pos = "center",
},
},
previewer = M.previewer(messages),
previewer = M.previewer(id_to_message),
fzf_opts = {
["--no-multi"] = "",
["--with-nth"] = "2..",
},
actions = {
default = function() end,
default = function(entry_str)
entry_str = entry_str[1]

local id = tonumber(entry_str:match("^%d+"))
local message_entry = id_to_message[id]

local buf = vim.api.nvim_create_buf(false, false)

vim.api.nvim_set_option_value("buftype", "nofile", { buf = buf })
vim.api.nvim_set_option_value("bufhidden", "wipe", { buf = buf })

vim.api.nvim_buf_set_keymap(buf, "n", "q", ":bd<CR>", { silent = true, noremap = true })
vim.api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(message_entry.ordinal, "\n"))

local formatted = Format.format(message_entry.message, "fzf_preview")
formatted:render(buf, Config.ns)

vim.api.nvim_win_set_buf(0, buf)
end,
},
})
local lines = vim.tbl_map(function(entry)
return entry.display
end, vim.tbl_values(messages))
end, vim.tbl_values(id_to_message))
return fzf.fzf_exec(lines, opts)
end

Expand Down

0 comments on commit 5dece46

Please sign in to comment.