fix(scratch): floating window title/footer hl groups

This commit is contained in:
Folke Lemaitre 2024-12-02 21:03:11 +01:00
parent 964d7ae99a
commit 6c25ab1108
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -60,6 +60,8 @@ local defaults = {
} }
Snacks.util.set_hl({ Snacks.util.set_hl({
Title = "FloatTitle",
Footer = "FloatFooter",
Key = "DiagnosticVirtualTextInfo", Key = "DiagnosticVirtualTextInfo",
Desc = "DiagnosticInfo", Desc = "DiagnosticInfo",
}, { prefix = "SnacksScratch" }) }, { prefix = "SnacksScratch" })
@ -184,6 +186,9 @@ function M.open(opts)
{ opts.name .. (vim.v.count1 > 1 and " " .. vim.v.count1 or "") }, { opts.name .. (vim.v.count1 > 1 and " " .. vim.v.count1 or "") },
{ " " }, { " " },
} }
for _, t in ipairs(opts.win.title) do
t[2] = t[2] or "SnacksScratchTitle"
end
local is_new = not uv.fs_stat(file) local is_new = not uv.fs_stat(file)
local buf = vim.fn.bufadd(file) local buf = vim.fn.bufadd(file)
@ -230,6 +235,9 @@ function M.open(opts)
table.insert(ret.opts.footer, { " " .. (key.desc or keymap) .. " ", "SnacksScratchDesc" }) table.insert(ret.opts.footer, { " " .. (key.desc or keymap) .. " ", "SnacksScratchDesc" })
end end
table.insert(ret.opts.footer, { " " }) table.insert(ret.opts.footer, { " " })
for _, t in ipairs(ret.opts.footer) do
t[2] = t[2] or "SnacksScratchFooter"
end
if opts.autowrite then if opts.autowrite then
vim.api.nvim_create_autocmd("BufHidden", { vim.api.nvim_create_autocmd("BufHidden", {
group = vim.api.nvim_create_augroup("snacks_scratch_autowrite_" .. buf, { clear = true }), group = vim.api.nvim_create_augroup("snacks_scratch_autowrite_" .. buf, { clear = true }),