This page looks best with JavaScript enabled

How to setup copilot in vim

 ·  ☕ 3 min read  ·  🐧 sysadmin

In this video I explained how to install proper version of nodejs and how to enable copilot in vim. See the project: https://github.com/github/copilot.vim

Tutorial

Before you can start using GitHub Copilot for Individuals, you will need to set up a free trial or subscription. See the URL below:
Managing your GitHub Copilot subscription for your personal account

Install git if do not have it installed

SLES | openSUSE Leap 15.4
1
sudo zypper install git
Debian
1
sudo apt install git
Red Hat
1
sudo dnf install git

Check installed vim version

vim -version

Install vim (9.0.0185 or newer) from source

1
2
3
4
5
6
7
8
cd $HOME
git clone https://github.com/vim/vim.git
cd $HOME/vim/src
NB_CORES=$(grep -c '^processor' /proc/cpuinfo)
export MAKEFLAGS="-j$((NB_CORES+1)) -l${NB_CORES}"
make
make test
sudo make install

Persistent settings

To get these settings persistent, just add in your .bashrc or .zshrc

1
2
NB_CORES=$(grep -c '^processor' /proc/cpuinfo)
export MAKEFLAGS="-j$((NB_CORES+1)) -l${NB_CORES}"

And then type:

1
source ~/.zshrc # or .bashrc

Issues

If there will be issues during the make or make test install missing libraries. make or make test will inform you what is exactly missing, so if any package is missing, tryto look for how to install it.

SLES | openSUSE Leap 15.4
1
sudo zypper install libncurses5 ncurses make gcc g++ libtool libtool-bin
Debian
1
sudo apt install libncurses-dev libtool libtool-bin make build-essential g++
Red Hat
1
sudo dnf install ncurses-devel make gcc g++ libtool 

Install nodejs using nvm

1
2
3
4
5
6
7
8
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
nvm --version
nvm list-remote
nvm install v20.2.0
node -v
nvm alias default 20.2.0
nvm use default
node -v

Install copilot

1
2
git clone https://github.com/github/copilot.vim.git \ 
  $HOME/.vim/pack/github/start/copilot.vim

Create a .vimrc file in your $HOME directory and put the below into it and save

1
2
cd $HOME
vim .vimrc
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
" Add numbers to each line on the left-hand side.
 set number

" Disable compatibility with vi which can cause unexpected issues.
set nocompatible

" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on

" The below line enables copilot
" Enable plugins and load plugin for the detected file type.
filetype plugin on

" Load an indent file for the detected file type.
filetype indent on

" Turn syntax highlighting on.
syntax on

Open vim

1
vim

Type

1
:Copilot setup

Copy the one-time code, open the provided URL http://github.com/login/device and type the one-time code. Pay 10 USD and use copilot.

Share on

sysadmin
WRITTEN BY
sysadmin
QA & Linux Specialist