@@ -310,8 +310,7 @@ function! copilot#agent#LspInit(agent_id, initialize_result) abort
310
310
if ! has_key (s: instances , a: agent_id )
311
311
return
312
312
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 ])
315
314
endfunction
316
315
317
316
function ! copilot#agent#LspExit (agent_id, code, signal) abort
@@ -462,20 +461,21 @@ function! copilot#agent#Settings() abort
462
461
return settings
463
462
endfunction
464
463
465
- function ! s: InitializeResult (result, agent) abort
464
+ function ! s: AfterInitialize (result, agent) abort
466
465
let a: agent .serverInfo = get (a: result , ' serverInfo' , {})
467
466
if ! has_key (a: agent , ' node_version' ) && has_key (a: result .serverInfo, ' nodeVersion' )
468
467
let a: agent .node_version = a: result .serverInfo.nodeVersion
469
468
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
474
472
let pending = get (a: agent , ' initialization_pending' , [])
475
473
if has_key (a: agent , ' initialization_pending' )
476
474
call remove (a: agent , ' initialization_pending' )
477
475
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})
479
479
for request in pending
480
480
call timer_start (0 , { _ - > s: SendRequest (a: agent , request) })
481
481
endfor
@@ -514,7 +514,7 @@ let s:vim_capabilities = {
514
514
function ! copilot#agent#New (... ) abort
515
515
let opts = a: 0 ? a: 1 : {}
516
516
let instance = {' requests' : {},
517
- \ ' editorConfiguration ' : get (opts, ' editorConfiguration' , {}),
517
+ \ ' settings ' : extend ( copilot#agent#Settings (), get (opts, ' editorConfiguration' , {}) ),
518
518
\ ' Close' : function (' s:AgentClose' ),
519
519
\ ' Notify' : function (' s:AgentNotify' ),
520
520
\ ' Request' : function (' s:AgentRequest' ),
@@ -538,13 +538,17 @@ function! copilot#agent#New(...) abort
538
538
if ! empty (node_version)
539
539
let instance.node_version = node_version
540
540
endif
541
- let opts = {' initializationOptions' : {}}
541
+ let opts = {}
542
+ let opts.initializationOptions = {
543
+ \ ' editorInfo' : copilot#agent#EditorInfo (),
544
+ \ ' editorPluginInfo' : copilot#agent#EditorPluginInfo (),
545
+ \ }
542
546
if has (' nvim' )
543
547
call extend (instance, {
544
548
\ ' Close' : function (' s:LspClose' ),
545
549
\ ' Notify' : function (' s:LspNotify' ),
546
550
\ ' 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 )" )
548
552
let instance.id = instance.client_id
549
553
else
550
554
let state = {' headers' : {}, ' mode' : ' headers' , ' buffer' : ' ' }
0 commit comments