@@ -310,8 +310,7 @@ function! copilot#agent#LspInit(agent_id, initialize_result) abort
310310 if ! has_key (s: instances , a: agent_id )
311311 return
312312 endif
313- let instance = s: instances [a: agent_id ]
314- call timer_start (0 , { _ - > s: InitializeResult (a: initialize_result , instance)})
313+ call s: AfterInitialize (a: initialize_result , s: instances [a: agent_id ])
315314endfunction
316315
317316function ! copilot#agent#LspExit (agent_id, code, signal) abort
@@ -462,20 +461,21 @@ function! copilot#agent#Settings() abort
462461 return settings
463462endfunction
464463
465- function ! s: InitializeResult (result, agent) abort
464+ function ! s: AfterInitialize (result, agent) abort
466465 let a: agent .serverInfo = get (a: result , ' serverInfo' , {})
467466 if ! has_key (a: agent , ' node_version' ) && has_key (a: result .serverInfo, ' nodeVersion' )
468467 let a: agent .node_version = a: result .serverInfo.nodeVersion
469468 endif
470- let info = {
471- \ ' editorInfo' : copilot#agent#EditorInfo (),
472- \ ' editorPluginInfo' : copilot#agent#EditorPluginInfo (),
473- \ ' editorConfiguration' : extend (copilot#agent#Settings (), a: agent .editorConfiguration)}
469+ endfunction
470+
471+ function ! s: InitializeResult (result, agent) abort
474472 let pending = get (a: agent , ' initialization_pending' , [])
475473 if has_key (a: agent , ' initialization_pending' )
476474 call remove (a: agent , ' initialization_pending' )
477475 endif
478- call a: agent .Request (' setEditorInfo' , info)
476+ call a: agent .Notify (' initialized' , {})
477+ call s: AfterInitialize (a: result , a: agent )
478+ call a: agent .Notify (' workspace/didChangeConfiguration' , {' settings' : a: agent .settings})
479479 for request in pending
480480 call timer_start (0 , { _ - > s: SendRequest (a: agent , request) })
481481 endfor
@@ -514,7 +514,7 @@ let s:vim_capabilities = {
514514function ! copilot#agent#New (... ) abort
515515 let opts = a: 0 ? a: 1 : {}
516516 let instance = {' requests' : {},
517- \ ' editorConfiguration ' : get (opts, ' editorConfiguration' , {}),
517+ \ ' settings ' : extend ( copilot#agent#Settings (), get (opts, ' editorConfiguration' , {}) ),
518518 \ ' Close' : function (' s:AgentClose' ),
519519 \ ' Notify' : function (' s:AgentNotify' ),
520520 \ ' Request' : function (' s:AgentRequest' ),
@@ -538,13 +538,17 @@ function! copilot#agent#New(...) abort
538538 if ! empty (node_version)
539539 let instance.node_version = node_version
540540 endif
541- let opts = {' initializationOptions' : {}}
541+ let opts = {}
542+ let opts.initializationOptions = {
543+ \ ' editorInfo' : copilot#agent#EditorInfo (),
544+ \ ' editorPluginInfo' : copilot#agent#EditorPluginInfo (),
545+ \ }
542546 if has (' nvim' )
543547 call extend (instance, {
544548 \ ' Close' : function (' s:LspClose' ),
545549 \ ' Notify' : function (' s:LspNotify' ),
546550 \ ' Request' : function (' s:LspRequest' )})
547- let instance.client_id = eval (" v:lua.require'_copilot'.lsp_start_client(command, keys(instance.methods), opts)" )
551+ let instance.client_id = eval (" v:lua.require'_copilot'.lsp_start_client(command, keys(instance.methods), opts, instance.settings )" )
548552 let instance.id = instance.client_id
549553 else
550554 let state = {' headers' : {}, ' mode' : ' headers' , ' buffer' : ' ' }
0 commit comments