4513ECHO / lspoints-copilot

lspoints extension for GitHub Copilot
MIT License
6 stars 1 forks source link

Copilot is not attached #1

Closed tani closed 1 month ago

tani commented 1 month ago

Thanks for the great project! I have the following problem. Could you help me? In the following configuration file, Copilot is not attached on first start.

let &rtp .= expandcmd(',<sfile>:p:h/denops.vim')
let &rtp .= expandcmd(',<sfile>:p:h/lspoints')
let &rtp .= expandcmd(',<sfile>:p:h/lspoints-extension-copilot')
let g:lspoints#extensions = ['copilot']
tani commented 1 month ago

As we discussed on slack, applying the following with reference to your changes worked! Thanks

diff --git a/autoload/lspoints/extension/copilot.vim b/autoload/lspoints/extension/copilot.vim
index ff22075..1a4f8d5 100644
--- a/autoload/lspoints/extension/copilot.vim
+++ b/autoload/lspoints/extension/copilot.vim
@@ -10,9 +10,7 @@ endfunction

 function! lspoints#extension#copilot#on_filetype() abort
   let b:copilot_disabled = v:true
-  if &l:modifiable && &l:buflisted
-    call lspoints#attach('copilot')
-  endif
+  call denops#plugin#wait_async('lspoints', { -> (&l:modifiable && &l:buflisted) && lspoints#attach('copilot') })
 endfunction

 function! lspoints#extension#copilot#on_insert_leave_pre() abort
@@ -45,9 +43,6 @@ function! s:trigger(bufnr, timer) abort
 endfunction

 function! lspoints#extension#copilot#on_buf_enter() abort
-  if !denops#plugin#is_loaded('lspoints')
-    call lspoints#denops#register()
-  endif
   call lspoints#denops#notify('executeCommand', ['copilot', 'notifyDidFocus', bufnr()])
 endfunction

@@ -68,9 +63,6 @@ function! lspoints#extension#copilot#initialize() abort
 endfunction

 function! lspoints#extension#copilot#suggest() abort
-  if !denops#plugin#is_loaded('lspoints')
-    call lspoints#denops#register()
-  endif
   call lspoints#denops#notify('executeCommand', ['copilot', 'suggest'])
 endfunction