@@ -34,45 +34,67 @@ function mod.version()
3434end
3535
3636function mod .status ()
37- local function on_output (err )
38- print (" [Copilot] " .. err )
37+ local lines = {}
38+
39+ local function add_line (line )
40+ lines [# lines + 1 ] = { " [Copilot] " .. line .. " \n " }
41+ end
42+
43+ local function flush_lines (last_line )
44+ if last_line then
45+ add_line (last_line )
46+ end
47+
48+ vim .api .nvim_echo (lines , true , {})
3949 end
4050
4151 local client = u .get_copilot_client ()
4252 if not client then
43- on_output (" Not running" )
53+ flush_lines (" Not running" )
4454 return
4555 end
4656
47- coroutine.wrap (function ()
48- --- @todo check startup error
57+ add_line (" Online" )
4958
59+ coroutine.wrap (function ()
5060 local cserr , status = a .check_status (client )
5161 if cserr then
52- on_output (cserr )
62+ flush_lines (cserr )
5363 return
5464 end
5565
56- --- @todo check enabled status
57-
5866 if not status .user then
59- on_output (" Not authenticated. Run ':Copilot auth'" )
67+ flush_lines (" Not authenticated. Run ':Copilot auth'" )
6068 return
6169 end
6270
71+ local should_attach , no_attach_reason = u .should_attach (c .params .filetypes )
72+ local is_attached = u .is_attached (client )
73+ if is_attached then
74+ if not should_attach then
75+ add_line (" Enabled manually (" .. no_attach_reason .. " )" )
76+ else
77+ add_line (" Enabled for " .. vim .bo .filetype )
78+ end
79+ elseif not is_attached then
80+ if should_attach then
81+ add_line (" Disabled manually for " .. vim .bo .filetype )
82+ else
83+ add_line (" Disabled (" .. no_attach_reason .. " )" )
84+ end
85+ end
86+
6387 if string.lower (a .status .data .status ) == " error" then
64- on_output (a .status .data .message )
65- return
88+ add_line (a .status .data .message )
6689 end
6790
68- on_output ( " Enabled and online " )
91+ flush_lines ( )
6992 end )()
7093end
7194
7295--- @param opts ? { force ?: boolean }
7396function mod .toggle (opts )
7497 opts = opts or {}
75- print (vim .inspect (opts ))
7698
7799 local client = u .get_copilot_client ()
78100 if not client then
0 commit comments