Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit57a0115

Browse files
committed
Copilot.vim 1.24.0
1 parent0754163 commit57a0115

File tree

6 files changed

+180
-147
lines changed

6 files changed

+180
-147
lines changed

‎autoload/copilot.vim

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,20 +432,31 @@ function! copilot#Schedule(...) abort
432432
letg:_copilot_timer=timer_start(delay,function('s:Trigger', [bufnr('')]))
433433
endfunction
434434

435-
function!s:SyncTextDocument(bufnr,...)abort
435+
function!s:Attach(bufnr,...)abort
436436
try
437-
returncopilot#Agent().SyncTextDocument(a:bufnr)
437+
returncopilot#Agent().Attach(a:bufnr)
438438
catch
439439
callcopilot#logger#Exception()
440440
endtry
441441
endfunction
442442

443443
function!copilot#OnFileType()abort
444-
ifempty(s:BufferDisabled())
445-
calltimer_start(0,function('s:SyncTextDocument', [bufnr('')]))
444+
ifempty(s:BufferDisabled())&& &l:modifiable&& &l:buflisted
445+
calltimer_start(0,function('s:Attach', [bufnr('')]))
446446
endif
447447
endfunction
448448

449+
function!s:Focus(bufnr,...)abort
450+
ifs:Running()&&copilot#Agent().IsAttached(a:bufnr)
451+
callcopilot#Agent().Notify('textDocument/didFocus', {'textDocument': {'uri':copilot#Agent().Attach(a:bufnr).uri}})
452+
endif
453+
endfunction
454+
455+
function!copilot#OnBufEnter()abort
456+
letbufnr=bufnr('')
457+
calltimer_start(0, { _->timer_start(0,function('s:Focus', [bufnr]))})
458+
endfunction
459+
449460
function!copilot#OnInsertLeave()abort
450461
returncopilot#Clear()
451462
endfunction

‎autoload/copilot/agent.vim

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ function! s:PreprocessParams(agent, params) abort
188188
for docinfilter([get(a:params,'doc', {}),get(a:params,'textDocument', {})],'type(get(v:val, "uri", "")) == v:t_number')
189189
letbufnr= doc.uri
190190
calls:RegisterWorkspaceFolderForBuffer(a:agent,bufnr)
191-
let synced=a:agent.SyncTextDocument(bufnr)
191+
let synced=a:agent.Attach(bufnr)
192192
let doc.uri= synced.uri
193-
let doc.version= synced.version
193+
let doc.version=get(synced,'version',0)
194194
endfor
195195
returnbufnr
196196
endfunction
197197

198-
function!s:VimSyncTextDocument(bufnr)dictabort
198+
function!s:VimAttach(bufnr)dictabort
199199
if!bufloaded(a:bufnr)
200200
return {'uri':'','version':0}
201201
endif
@@ -223,6 +223,10 @@ function! s:VimSyncTextDocument(bufnr) dict abort
223223
return doc
224224
endfunction
225225

226+
function!s:VimIsAttached(bufnr)dictabort
227+
returnbufloaded(a:bufnr)&&has_key(self.open_buffers,a:bufnr) ?v:true :v:false
228+
endfunction
229+
226230
function!s:AgentRequest(method, params,...)dictabort
227231
lets:id+=1
228232
let params=deepcopy(a:params)
@@ -365,14 +369,18 @@ function! copilot#agent#LspResponse(agent_id, opts, ...) abort
365369
calls:OnResponse(s:instances[a:agent_id],a:opts)
366370
endfunction
367371

368-
function!s:NvimSyncTextDocument(bufnr)dictabort
372+
function!s:NvimAttach(bufnr)dictabort
369373
if!bufloaded(a:bufnr)
370374
return {'uri':'','version':0}
371375
endif
372376
callluaeval('pcall(vim.lsp.buf_attach_client, _A[1], _A[2])', [a:bufnr,self.id])
373377
returnluaeval('{uri = vim.uri_from_bufnr(_A), version = vim.lsp.util.buf_versions[_A]}',a:bufnr)
374378
endfunction
375379

380+
function!s:NvimIsAttached(bufnr)dictabort
381+
returnbufloaded(a:bufnr) ?luaeval('vim.lsp.buf_is_attached(_A[1], _A[2])', [a:bufnr,self.id]) :v:false
382+
endfunction
383+
376384
function!s:LspRequest(method, params,...)dictabort
377385
let params=deepcopy(a:params)
378386
letbufnr=s:PreprocessParams(self, params)
@@ -575,7 +583,8 @@ function! copilot#agent#New(...) abort
575583
\'Close':function('s:AgentClose'),
576584
\'Notify':function('s:AgentNotify'),
577585
\'Request':function('s:AgentRequest'),
578-
\'SyncTextDocument':function('s:VimSyncTextDocument'),
586+
\'Attach':function('s:VimAttach'),
587+
\'IsAttached':function('s:VimIsAttached'),
579588
\'Call':function('s:AgentCall'),
580589
\'Cancel':function('s:AgentCancel'),
581590
\'StartupError':function('s:AgentStartupError'),
@@ -622,7 +631,8 @@ function! copilot#agent#New(...) abort
622631
\'Close':function('s:LspClose'),
623632
\'Notify':function('s:LspNotify'),
624633
\'Request':function('s:LspRequest'),
625-
\'SyncTextDocument':function('s:NvimSyncTextDocument'),
634+
\'Attach':function('s:NvimAttach'),
635+
\'IsAttached':function('s:NvimIsAttached'),
626636
\})
627637
let instance.client_id=eval("v:lua.require'_copilot'.lsp_start_client(command, keys(instance.methods), opts, instance.settings)")
628638
let instance.id= instance.client_id

‎autoload/copilot/version.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function!copilot#version#String()abort
2-
return'1.23.0'
2+
return'1.24.0'
33
endfunction

‎dist/agent.js

Lines changed: 144 additions & 133 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎dist/agent.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎plugin/copilot.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ augroup github_copilot
5757
autocmdBufLeave*ifmode()=~#'^[iR]'|calls:Event('InsertLeave')|endif
5858
autocmdInsertEnter*calls:Event('InsertEnter')
5959
autocmdBufEnter*ifmode()=~#'^[iR]'|calls:Event('InsertEnter')|endif
60+
autocmdBufEnter*calls:Event('BufEnter')
6061
autocmdCursorMovedI*calls:Event('CursorMovedI')
6162
autocmdCompleteChanged*calls:Event('CompleteChanged')
6263
autocmdColorScheme,VimEnter*calls:ColorScheme()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp