File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
git-prompt-string-lualine Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -45,15 +45,24 @@ M.git_prompt_string_json = function()
45
45
table.insert (cmd , ' --color-disabled' )
46
46
end
47
47
local stdout = ' '
48
+ local job_id
48
49
-- replace with vim.system if/when we no longer support neovim v9
49
- local job_id = vim .fn .jobstart ( cmd , {
50
+ local status , result = pcall ( vim .fn .jobstart , cmd , {
50
51
cwd = opts .cwd ,
51
52
stdout_buffered = true ,
52
53
stderr_buffered = true ,
53
54
on_stdout = function (_ , data )
54
55
stdout = table.concat (data , ' ' )
55
56
end ,
56
57
})
58
+
59
+ if status then
60
+ job_id = result
61
+ else
62
+ vim .notify_once (' git-prompt-string-lualine.nvim: ERROR ' .. result , vim .log .levels .ERROR , {})
63
+ return { error = result , color = ' error' }
64
+ end
65
+
57
66
vim .fn .jobwait ({ job_id })
58
67
local json = vim .json .decode (stdout == ' ' and ' {}' or stdout )
59
68
return {
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ function M:init(options)
45
45
untracked = self :create_hl (self .options .prompt_config .color_untracked , ' untracked' ),
46
46
no_upstream = self :create_hl (self .options .prompt_config .color_no_upstream , ' no_upstream' ),
47
47
merging = self :create_hl (self .options .prompt_config .color_merging , ' merging' ),
48
+ error = self :create_hl (' ErrorMsg' , ' error' ),
48
49
}
49
50
end
50
51
@@ -63,10 +64,14 @@ function M:update_status()
63
64
self .options .icon_color_highlight = self .highlights [prompt .color ]
64
65
self .options .color_highlight = self .highlights [prompt .color ]
65
66
end
66
- if self .options .trim_prompt_prefix then
67
+ if self .options .trim_prompt_prefix and prompt . prompt_prefix then
67
68
prompt .prompt_prefix = prompt .prompt_prefix :gsub (' ^%s+' , ' ' )
68
69
end
69
- return prompt .prompt_prefix .. prompt .branch_info .. prompt .branch_status .. prompt .prompt_suffix
70
+ return (prompt .error or ' ' )
71
+ .. (prompt .prompt_prefix or ' ' )
72
+ .. (prompt .branch_info or ' ' )
73
+ .. (prompt .branch_status or ' ' )
74
+ .. (prompt .prompt_suffix or ' ' )
70
75
end
71
76
72
77
return M
You can’t perform that action at this time.
0 commit comments