Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lua/git-prompt-string-lualine/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ M.git_prompt_string_json = function()
table.insert(cmd, '--color-disabled')
end
local stdout = ''
local stderr = ''
local job_id
-- replace with vim.system if/when we no longer support neovim v9
local status, result = pcall(vim.fn.jobstart, cmd, {
Expand All @@ -54,6 +55,9 @@ M.git_prompt_string_json = function()
on_stdout = function(_, data)
stdout = table.concat(data, '')
end,
on_stderr = function(_, data)
stderr = table.concat(data, '')
end,
})

if status then
Expand All @@ -63,7 +67,17 @@ M.git_prompt_string_json = function()
return { error = result, color = 'error' }
end

vim.fn.jobwait({ job_id })
local exit_code = vim.fn.jobwait({ job_id })[1]

if exit_code ~= 0 then
vim.notify_once(
'git-prompt-string-lualine.nvim: ERROR ' .. stderr .. stdout,
vim.log.levels.ERROR,
{}
)
return { error = stderr .. stdout, color = 'error' }
end

local json = vim.json.decode(stdout == '' and '{}' or stdout)
return {
color = json.color or '',
Expand Down