Marek Gibney

Try Copilot in Vim in Docker

So I decided to finally give GitHub Copilot a spin. Let's see how our new robot overlords are doing in terms of programming!

Turns out there is no way to just go to a website, start typing and see the magic in action. There is a plugin for Neovim, but I don't like to install stuff that is not in the Debian repos. Docker to the rescue!

As with anything I do manually, I put the steps into a script, so I don't have to do it again. And so I can share them. So here it is, the script to easily try Copilot in Vim in Docker.

Unfortunately it is a "script" that you have to execute manually line by line. Since it switches in and out of the container and needs you to manually register a token shown by the plugin during the setup. If the plugin setup was non-interactive, it all could be done in a Dockerfile.

docker run --name copilotcontainer -it debian:sid-slim

apt update && apt upgrade -y

apt install -y neovim nodejs git

git clone https://github.com/github/copilot.vim.git ~/.config/nvim/pack/github/start/copilot.vim

vim

# Now in vim type:
# :Copilot setup
# And then hit enter
# The plugin will display a token.
# Open a browser and paste the code on https://github.com/login/device
# After a few moments, the plugin will finish the setup
# Now exit vim
# Exit the container

docker commit copilotcontainer copilot

docker rm copilotcontainer

## All done

# From now on, you can use the copilot container with:
# docker run --rm -it copilot

When you run vim and go into insert mode, the plugin constantly suggests stuff. Here I typed the colorized code and Copilot suggests the grey code: