copilot.el
copilot.el copied to clipboard
feat: Use the latest server
Fix #304.
I have tried using copilot 1.30.0 locally with copilot.el and it fails to work correctly - ie it doesn't appear to return any completions, and when running copilot-diagnose I see the following:
Copilot error: (:code -32002 :message "Agent service not initialized.")
it looks like a significant reworking of the protocol between the local nodejs server and the client (either in vim or emacs) happened in the 1.28.0 release - see https://github.com/github/copilot.vim/commit/f45ecd95c1474885e278f20d6ae86a6e30de2151 for details - so I think copilot.el would need similar updates to work with this newer version
it looks like a significant reworking of the protocol between the local nodejs server and the client (either in vim or emacs) happened in the 1.28.0 release - see github/copilot.vim@f45ecd9 for details - so I think copilot.el would need similar updates to work with this newer version
could the default be brought forward to 1.27.0 perhaps?
edit: I've opened https://github.com/copilot-emacs/copilot.el/pull/314
Looking at the code of the vim plugin, it looks like the node server is a LSP server with support for textDocument/inlineCompletion. One option would be to let lsp-mode handle all the I/O (such as here and make the UI simply interact with it
Wrapping the lsp-inline-completion in a with-lsp-workspace workspace would ensure that only result from the target server are called:
(defun copilot-inline-completions ()
(interactive)
(-when-let (workspace (--some (lsp-find-workspace it (buffer-file-name))
'(copilot-lsp copilot-lsp-remote)))
(with-lsp-workspace workspace (lsp-inline-completion))))
I'll try to run the node server with lsp-mode and I'll let you know if it worked as expected
Yup, it kinda works -- https://github.com/kassick/copilot-lsp
copilot-lsp + gitlab-lsp + lsp-inline-completions (plus an upstream fix to lsp-mode) displays the inline completions
could the default be brought forward to 1.27.0 perhaps?
@jidicula Does it solve the issue if we used this version? 🤔
@jidicula Does it solve the issue if we used this version? 🤔
the issue as in "it starts when using the latest version of the server"? I'm using version 1.37.0 -- it starts, it completes when asking for inlineCompletions, so, for this, it does.
But the solution in my repo goes in a rather different direction -- use lsp-mode to do the I/O, instead of using json-rpc. It lets all the typical issues (document sync, start/restart, callbacks after completion, etc.) to lsp-mode to handle.
One may try to backport the relevant portions of lsp-mode to copilot.el or go in the direction I went in the POC -- I'm not certain which is best, TBH.
(it the issue is the reason why this MR was trying to upgrade to >=1.30.0, then I have no idea, sorry ;) )