Skip to content

Commit

Permalink
support for ghost icon
Browse files Browse the repository at this point in the history
  • Loading branch information
wd60622 committed Dec 11, 2024
1 parent dfb292d commit d30628a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lua/octo/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ local M = {}
---@field reaction_viewer_hint_icon string
---@field users string
---@field user_icon string
---@field ghost_icon string
---@field comment_icon string
---@field outdated_icon string
---@field resolved_icon string
Expand Down Expand Up @@ -111,6 +112,7 @@ function M.get_default_values()
reaction_viewer_hint_icon = "",
users = "search",
user_icon = "",
ghost_icon = "󰊠 ",
comment_icon = "",
outdated_icon = "󰅒 ",
resolved_icon = "",
Expand Down Expand Up @@ -439,6 +441,7 @@ function M.validate_config()
validate_type(config.reaction_viewer_hint_icon, "reaction_viewer_hint_icon", "string")
validate_string_enum(config.users, "users", { "search", "mentionable", "assignable" })
validate_type(config.user_icon, "user_icon", "string")
validate_type(config.ghost_icon, "ghost_icon", "string")
validate_type(config.comment_icon, "comment_icon", "string")
validate_type(config.outdated_icon, "outdated_icon", "string")
validate_type(config.resolved_icon, "resolved_icon", "string")
Expand Down
4 changes: 3 additions & 1 deletion lua/octo/model/octo-buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ function OctoBuffer:new(opts)
this.taggable_users = { this.node.author.login }
elseif this.node and this.number then
this.kind = "issue"
this.taggable_users = { this.node.author.login }
if not utils.is_blank(this.node.author) then
this.taggable_users = { this.node.author.login }
end
elseif this.node and not this.number then
this.kind = "repo"
else
Expand Down
4 changes: 2 additions & 2 deletions lua/octo/ui/bubbles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ local function make_user_bubble(name, is_viewer, opts)
local conf = config.values
local highlight = is_viewer and "OctoUserViewer" or "OctoUser"
local icon_position = opts.icon_position or "left"
local icon = conf.user_icon
icon = opts.icon or icon
local default_icon = opts.ghost and conf.ghost_icon or conf.user_icon
local icon = opts.icon or default_icon
local content
if icon_position == "left" then
content = icon .. " " .. name
Expand Down
25 changes: 19 additions & 6 deletions lua/octo/ui/writers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ function M.write_details(bufnr, issue, update)

-- author
local author_vt = { { "Created by: ", "OctoDetailsLabel" } }
local author_bubble = bubbles.make_user_bubble(issue.author.login, issue.viewerDidAuthor)
local opts = {}
if utils.is_blank(issue.author) then
issue.author = { login = "ghost" }
opts = { ghost = true }
end
local author_bubble = bubbles.make_user_bubble(issue.author.login, issue.viewerDidAuthor, opts)

vim.list_extend(author_vt, author_bubble)
table.insert(details, author_vt)
Expand Down Expand Up @@ -1261,11 +1266,19 @@ function M.write_issue_summary(bufnr, issue, opts)
end

-- author line
table.insert(chunks, {
{ " " },
{ conf.user_icon or "" },
{ issue.author.login },
})
if utils.is_blank(issue.author) then
table.insert(chunks, {
{ " " },
{ conf.ghost_icon or "󰊠 " },
{ "ghost" },
})
else
table.insert(chunks, {
{ " " },
{ conf.user_icon or "" },
{ issue.author.login },
})
end

for i = 1, #chunks do
M.write_block(bufnr, { "" }, i)
Expand Down

0 comments on commit d30628a

Please sign in to comment.