nix/home-manager/nvim/config/lua/lualine-config.lua

50 lines
1.2 KiB
Lua
Raw Permalink Normal View History

-- Cached variable
local cached_pr_status = ""
-- Read process output
local function read_output(err, data)
if err then return end
if not data then return end
cached_pr_status = data
end
-- Spawn process
local function execute_command()
local stdout = vim.loop.new_pipe(false)
local spawn_opts = {
detached = true,
stdio = {nil, stdout, nil},
2024-04-26 15:39:10 +00:00
args = {"-c", "gh pr checks | awk -F'\t' '{ print $2 }'"}
}
vim.loop.spawn("bash", spawn_opts,
function() stdout:read_start(read_output) end)
end
-- Spawn & schedule process
execute_command()
vim.fn.timer_start(300000, execute_command)
-- Return status from cache
function pr_status()
--   
2024-04-26 15:39:10 +00:00
--    
--
-- PENDING COLOR - #d29922
-- PASS COLOR - #3fb950
-- FAIL COLOR - #f85149
return cached_pr_status:gsub("\n", ""):gsub("fail", ""):gsub("pass",
"")
2024-04-26 15:39:10 +00:00
:gsub("pending", ""):gsub("skipping", ""):sub(1, -2)
end
2022-11-30 19:12:27 +00:00
require('lualine').setup({
options = {
theme = "gruvbox_dark"
-- theme = "nord"
-- theme = "OceanicNext",
},
sections = {lualine_c = {{pr_status}}}
2022-11-30 19:12:27 +00:00
})