Skip to content

yanghuaxuan/flight-attendant.el

 
 

Repository files navigation

flight-attendant.el - unofficial Emacs Copilot integration

This is a quite unsophisticated attempt to get GitHub Copilot up and running in Emacs. https://github.com/cryptobadger/flight-attendant.el/blob/media/pics/example-out.png?raw=true

What i did:

  • Look at a copilot plugin for nvim and reuse the copilot executable
  • Find a project that leverages the output of an executable in the same way we need it here and without as much overhead as the LSP implementations. (elpy)
  • Implement the necessary calls for authentication and completion requests

For now the integrated minor mode fa-mode only activates on Python files but extending it to other languages should be trivial. What needs to be done: Find a way to display the suggestions that does not interfere as much with company and probably a dozen other features as the current way.

Project structure, layout and most of the code is taken from the wonderful elpy. As a means of showing my respect and admiration I decided to fork the codebase to make it obvious that most of this is not my work. As we all I only stand on the shoulders of giants.

I am looking for help and advice.

Disclaimer

This software is 100% untested and not even remotely near alpha stage. It will break and it tends to mess up the buffer display. Neither GitHub nor the developers of elpy and the neovim github copilot plugin gave their permission to reuse their code - if you are one of the authors and object my reusage feel free to leave me a message. In the spirit of open source software however I think it is great that I am able to make use of their code and I am deeply thankful to them for the work they did on their projects. As i altered and reused code from elpy i will add the LICENSE file delivered with it.

Setup Instructions

You need to have access to the github Copilot program. Since i did not yet implement the “activation” process you need to complete it using another editor, e.g. nvim. After that a hosts.json should be in your config/github-copilot folder. (On linux: "~/.config/github-copilot/hosts.json").

  1. clone this project
  2. clone https://github.com/github/copilot.vim and copy the copilot directory to the flight-attendant.el project folder
  3. run
    (add-to-list 'load-path "/path/to/repo/")
    (load "flight-attendant.el")
    (fa-enable)
        

For friends of copy + paste:

git clone https://github.com/cryptobadger/flight-attendant.el;
git clone https://github.com/github/copilot.vim;
cp -r copilot.vim/copilot flight-attendant.el/;
emacs --eval "(progn (add-to-list 'load-path \"flight-attendant.el/\") (load \"flight-attendant.el\") (fa-enable))"

Display Completions

Below is the problem: https://github.com/cryptobadger/flight-attendant.el/blob/media/pics/company-bug.png?raw=true Any ideas how to display the completion candidate(s?) properly is welcome.

Roadmap/Todo

Sorted by urgency.

  • [ ] fix/find a solution for the question how to display hints
    • as company entries?
    • as in nvim/vs code (the current solution is close but messes up the buffer)
  • [ ] decide on keybindings
  • [ ] implement accepting the suggestion
  • [ ] allow initial generation of “copilot oauth token”
  • [ ] refactor, clean up code, look at en-/disabling for different languages
  • [ ] add instructions how to use with straight/use-package
  • [ ] build doom module
  • [ ] achieve feature parity with vscode

About

UNOFFICIAL Emacs Copilot Integration

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Emacs Lisp 100.0%