11local a = require (" copilot.api" )
22local c = require (" copilot.client" )
3+ local config = require (" copilot.config" )
34local u = require (" copilot.util" )
45
56local mod = {}
67
8+ local function node_version_warning (node_version )
9+ if string.match (node_version , " ^16%." ) then
10+ local line = " Warning: Node.js 16 is approaching end of life and support will be dropped in a future release."
11+ if config .get (" copilot_node_command" ) ~= " node" then
12+ line = line
13+ .. " 'copilot_node_command' is set to a non-default value. Consider removing it from your configuration."
14+ end
15+ return { line , " WarningMsg" }
16+ end
17+ end
18+
719function mod .version ()
820 local info = u .get_editor_info ()
921
22+ --- @type (string | table )[]
1023 local lines = {
1124 info .editorInfo .name .. " " .. info .editorInfo .version ,
1225 " copilot.vim" .. " " .. info .editorPluginInfo .version ,
@@ -25,41 +38,49 @@ function mod.version()
2538
2639 local node_version = c .get_node_version ()
2740 lines [# lines + 1 ] = " Node.js" .. " " .. (# node_version == 0 and " (unknown)" or node_version )
41+ lines [# lines + 1 ] = node_version_warning (node_version )
42+
43+ local chunks = {}
44+ for _ , line in ipairs (lines ) do
45+ chunks [# chunks + 1 ] = type (line ) == " table" and line or { line }
46+ chunks [# chunks + 1 ] = { " \n " , " NONE" }
47+ end
2848
29- vim .api .nvim_echo (
30- vim .tbl_map (function (line )
31- return { line .. " \n " }
32- end , lines ),
33- true ,
34- {}
35- )
49+ vim .api .nvim_echo (chunks , true , {})
3650 end )()
3751end
3852
3953function mod .status ()
4054 local lines = {}
4155
4256 local function add_line (line )
43- lines [# lines + 1 ] = { " [Copilot] " .. line .. " \n " }
57+ if not line then
58+ return
59+ end
60+
61+ lines [# lines + 1 ] = type (line ) == " table" and line or { " [Copilot] " .. line }
62+ lines [# lines + 1 ] = { " \n " , " NONE" }
4463 end
4564
46- local function flush_lines (last_line )
47- if last_line then
48- add_line (last_line )
65+ local function flush_lines (last_line , is_off )
66+ add_line (last_line )
67+
68+ if not is_off then
69+ add_line (node_version_warning (c .get_node_version ()))
4970 end
5071
5172 vim .api .nvim_echo (lines , true , {})
5273 end
5374
5475 if c .is_disabled () then
5576 add_line (" Offline" )
56- flush_lines (c .startup_error )
77+ flush_lines (c .startup_error , true )
5778 return
5879 end
5980
6081 local client = c .get ()
6182 if not client then
62- flush_lines (" Not Started" )
83+ flush_lines (" Not Started" , true )
6384 return
6485 end
6586
0 commit comments