@@ -37,16 +37,21 @@ local job_id = nil
37
37
local err_exit = false
38
38
local has_05 = vim .api .nvim_call_function (" has" , {" nvim-0.5" }) == 1
39
39
40
+ local echo = function (msg , error )
41
+ if has_05 then
42
+ vim .api .nvim_echo ({{msg , error and " ErrorMsg" or nil }}, true , {})
43
+ elseif error then
44
+ vim .api .nvim_err_write (msg )
45
+ else
46
+ vim .api .nvim_out_write (msg )
47
+ end
48
+ end
49
+
40
50
chad .on_exit = function (args )
41
51
local code = unpack (args )
42
52
if not (code == 0 or code == 143 ) then
43
- local msg = " CHADTree EXITED - " .. code
44
53
err_exit = true
45
- if has_05 then
46
- vim .api .nvim_echo ({{msg , " ErrorMsg" }}, true , {})
47
- else
48
- vim .api .nvim_err_writeln (msg )
49
- end
54
+ echo (" CHADTree EXITED - " .. code , true )
50
55
else
51
56
err_exit = false
52
57
end
55
60
56
61
chad .on_stdout = function (args )
57
62
local msg = unpack (args )
58
- local lines = table.concat (msg , linesep )
59
-
60
- if has_05 then
61
- vim .api .nvim_echo ({{lines }}, true , {})
62
- else
63
- vim .api .nvim_out_write (lines )
64
- end
63
+ echo (table.concat (msg , linesep ), false )
65
64
end
66
65
67
66
chad .on_stderr = function (args )
68
67
local msg = unpack (args )
69
- local lines = table.concat (msg , linesep )
70
-
71
- if has_05 then
72
- vim .api .nvim_echo ({{lines , " ErrorMsg" }}, true , {})
73
- else
74
- vim .api .nvim_err_write (lines )
75
- end
68
+ echo (table.concat (msg , linesep ), true )
76
69
end
77
70
78
71
local go , _py3 = pcall (vim .api .nvim_get_var , " python3_host_prog" )
0 commit comments