From 2ca8399aea5159112feb9f24ebf6a86b9b6575e7 Mon Sep 17 00:00:00 2001 From: Yuki Ito Date: Sun, 3 Nov 2024 00:05:15 +0900 Subject: [PATCH] fix: remove unnecessary spaces when the icon is empty --- lua/notify/render/default.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lua/notify/render/default.lua b/lua/notify/render/default.lua index 3213f16..08202dc 100644 --- a/lua/notify/render/default.lua +++ b/lua/notify/render/default.lua @@ -2,7 +2,7 @@ local api = vim.api local base = require("notify.render.base") return function(bufnr, notif, highlights, config) - local left_icon = notif.icon .. " " + local left_icon = notif.icon == "" and "" or notif.icon .. " " local max_message_width = math.max(math.max(unpack(vim.tbl_map(function(line) return vim.fn.strchars(line) end, notif.message)))) @@ -16,12 +16,11 @@ return function(bufnr, notif, highlights, config) local namespace = base.namespace() api.nvim_buf_set_lines(bufnr, 0, 1, false, { "", "" }) + + local virt_text = left_icon == "" and {} or { { " " }, { left_icon, highlights.icon } } + table.insert(virt_text, { left_title .. left_buffer, highlights.title }) api.nvim_buf_set_extmark(bufnr, namespace, 0, 0, { - virt_text = { - { " " }, - { left_icon, highlights.icon }, - { left_title .. left_buffer, highlights.title }, - }, + virt_text = virt_text, virt_text_win_col = 0, priority = 10, })