Skip to content

Commit

Permalink
Add MastodonMetadata highlight group
Browse files Browse the repository at this point in the history
closes #30

* Refactors the Mastodon plugin to use a new `MastodonMetadata` highlight group
  for rendering metadata in the buffer.
* Previously, the plugin was using the `Whitespace` highlight group,
  which was not appropriate for this purpose.

The new `MastodonMetadata` highlight group is defined with the same foreground
 and background colors as the `NormalFloat` highlight group, with a blend value
 of 10 to provide semi-transparent color. This ensures that the metadata
 could not seen as bloated

These changes improve the readability of Mastodon Buffer
  • Loading branch information
malkoG committed Sep 30, 2023
1 parent 962fe09 commit bf51981
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lua/mastodon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ M.setup = function(args)
M.config = vim.tbl_deep_extend("force", M.config, args or {})

namespace = vim.api.nvim_create_namespace("MastodonNS")
local hl_for_whitespace = vim.api.nvim_get_hl(0, { name = "NormalFloat" })

vim.api.nvim_set_hl(namespace, "MastodonHandle", {
fg = "#000000",
bg = "#ffffff",
underline = true,
})
vim.api.nvim_set_hl(namespace, "MastodonMetadata", {
fg = hl_for_whitespace.bg,
bg = hl_for_whitespace.bg,
blend = 10,
})
end

M.toot_message = function()
Expand Down
3 changes: 2 additions & 1 deletion lua/mastodon/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ local function render_statuses(bufnr, win, statuses, buf_name, mode)

for _, metadata_for_line in ipairs(metadata) do
vim.api.nvim_buf_set_extmark(bufnr, mastodon_ns, offset + metadata_for_line.line_number, 0, {
virt_text = { { metadata_for_line.data, "Whitespace" } },
virt_text = { { metadata_for_line.data, "MastodonMetadata" } },
hl_mode = "blend",
})
end

Expand Down

0 comments on commit bf51981

Please sign in to comment.