From 5b812b307a7b4491ddcc3b0a8f298039f53672bd Mon Sep 17 00:00:00 2001 From: Beau Date: Fri, 5 Feb 2021 08:12:35 +1100 Subject: [PATCH] Don't show signify status symbols if the count < 1 (#83) * Don't show signify status symbols if the count < 1 --- lua/lualine/components/signify.lua | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/lua/lualine/components/signify.lua b/lua/lualine/components/signify.lua index 348af52..d0b79b8 100644 --- a/lua/lualine/components/signify.lua +++ b/lua/lualine/components/signify.lua @@ -2,12 +2,29 @@ local function signify() if vim.fn.exists('*sy#repo#get_stats') == 0 then return '' end local added, modified, removed = unpack(vim.fn['sy#repo#get_stats']()) if added == -1 then return '' end - local data = { - '+'..added, - '-'..removed, - '~'..modified, + local symbols = { + '+', + '-', + '~', } - return table.concat(data, ' ') + local result = {} + local data = { + added, + removed, + modified, + } + for range=1,3 do + if data[range] ~= nil and data[range] > 0 + then table.insert(result,symbols[range]..''..data[range]..' ') + end + end + + if result[1] ~= nil then + return table.concat(result, '') + else + return '' + end end + return signify