README.org

March 26, 2022 ยท View on GitHub

#+TITLE: flight-attendant.el - unofficial Emacs Copilot integration

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

What i did:

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. [[https://github.com/neovim/neovim][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

    • using use-package #+begin_src sh git clone git@github.com:fkr-0/flight-attendant.el.git #+end_src

    #+begin_src emacs-lisp (use-package flight-attendant :config (setq fa-copilot-path (expand-file-name "/path/to/nvim/agent.js") fa-oauth-token (expand-file-name "/path/to/github-copilot/hosts.json")) :load-path "~/code/flight-attendant.el/") #+end_src

    • using [[https://github.com/hlissner/doom-emacs][doom]] emacs
      • package.el #+begin_src emacs-lisp ;; for devs (package! flight-attendant :recipe (:local-repo "~/local/clone/of/flight-attendant.el/" :build (:not compile))) ;; else (package! flight-attendant :recipe (:host github :repo "fkr-0/flight-attendant.el")) #+end_src
      • config.el #+begin_src emacs-lisp (use-package! flight-attendant :config (setq fa-copilot-path (expand-file-name "/path/to/nvim/agent.js") fa-oauth-token (expand-file-name "/.config/github-copilot/hosts.json"))) #+end_src

** 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 [[https://github.com/hlissner/doom-emacs][doom]] module
  • achieve feature parity with vscode