From d30628a8c7af23adf3b0375a3c175cbdd15dc5a3 Mon Sep 17 00:00:00 2001 From: Will Dean Date: Wed, 11 Dec 2024 21:29:46 +0100 Subject: [PATCH] support for ghost icon --- lua/octo/config.lua | 3 +++ lua/octo/model/octo-buffer.lua | 4 +++- lua/octo/ui/bubbles.lua | 4 ++-- lua/octo/ui/writers.lua | 25 +++++++++++++++++++------ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lua/octo/config.lua b/lua/octo/config.lua index a608f605..f860230d 100644 --- a/lua/octo/config.lua +++ b/lua/octo/config.lua @@ -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 @@ -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 = " ", @@ -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") diff --git a/lua/octo/model/octo-buffer.lua b/lua/octo/model/octo-buffer.lua index 3042ee58..e9be456d 100644 --- a/lua/octo/model/octo-buffer.lua +++ b/lua/octo/model/octo-buffer.lua @@ -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 diff --git a/lua/octo/ui/bubbles.lua b/lua/octo/ui/bubbles.lua index d431dbcc..daadba56 100644 --- a/lua/octo/ui/bubbles.lua +++ b/lua/octo/ui/bubbles.lua @@ -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 diff --git a/lua/octo/ui/writers.lua b/lua/octo/ui/writers.lua index 1dc84f0c..6469a089 100644 --- a/lua/octo/ui/writers.lua +++ b/lua/octo/ui/writers.lua @@ -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) @@ -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)