Install Github Copilot to NeoVim
👨✈️Copilot code suggestions at hand 👋

Once a programmer set a chatbot to write a program that passes the test of “I am not a robot“ the chatbot did the best it could do destroying itself — The guy who loves Chatbots
I have my editor running at same time with others apps consuming lots of memory so I want to use them wisely. I found that light editors like Neovim and NvChad have the option of having AI installed so I though it was a good chance to try to setup myself. So here I present what I learned about it.
Config Lazy Vim
open NvChad plugin file ~/.config/nvim/lua/custom/plugins.lua and paste this
return {
{
"github/copilot.vim",
cmd = "Copilot",
},
}
"github/copilot.vim"→ the official Copilot plugin repocmd = "Copilot"→ lazy‑load only when you run Copilot commands
Add Copilot to NvChad
- check for where NodeJs binary is stored. I had to use
which node
I got a simlink like /run/user/1000/fnm_multishells/9702_1764251384693/bin/node
Then i read the link to get the folder where bynary is stored
readlink -f /run/user/1000/fnm_multishells/9702_1764251384693/bin/node
reading the link provided a NodeJs binary folder. something like
/home/user/.local/share/fnm/node-versions/v22.20.0/installation/bin/node
Create a new file for Copilot plugin Inside
~/.config/nvim/lua/plugins/copilot.lua. and paste this code. Make sure to replace<your_node_folder>with the result of step 1return { "github/copilot.vim", -- enable copilot when you access a filetype with code event = "InsertEnter", config = function() vim.g.copilot_node_command = "<your_node_folder>" -- enable Copilot globally at startup vim.g.copilot_enabled = true -- optional: enable Copilot by default vim.g.copilot_no_tab_map = true vim.g.copilot_assume_mapped = true vim.g.copilot_tab_fallback = "" -- Accept suggestion with Ctrl-J vim.api.nvim_set_keymap("i", "<C-j>", 'copilot#Accept("<CR>")', { expr = true, silent = true }) -- Cycle suggestions vim.api.nvim_set_keymap("i", "<C-k>", "<Plug>(copilot-next)", {}) vim.api.nvim_set_keymap("i", "<C-h>", "<Plug>(copilot-previous)", {}) -- Dismiss suggestion vim.api.nvim_set_keymap("i", "<C-c>", "<Plug>(copilot-dismiss)", {}) end, }"github/copilot.vim"→ official Copilot pluginevent = "InsertEnter"→ load when you enter insert mode in a file that has codeconfigblock → optional tweaks for keymaps. in this case we usectrl+jto accept a code suggestion
Sync plugins Open Neovim and run:
:Lazy syncThis will download Copilot into
.local/share/nvim/lazy/copilot.vim.Restart Neovim so the plugin loads.
Run setup Now you can do:
:Copilot setupThis will open a browser to authenticate with GitHub.
In my case I got this error after authentication.
after :Lazy sync i got this ERROR
Total: 28 plugins
Failed (1) LuaSnip 62.33ms nvim-cmp
fatal: not a git repository: ../../.git/modules/deps/jsregexp006
fatal: could not reset submodule index
How to fix LuaSnip Submodule Error
I used this fix
rm -rf ~/.local/share/nvim/lazy/LuaSnip
git clone --recursive https://github.com/L3MON4D3/LuaSnip ~/.local/share/nvim/lazy/LuaSnip
after that I could use
:Copilot setup
- Use this command to start copilot each time you start NVim (I need to check for a way to autostart it)
You will get a one time code that you need to take note. Follow the wizard and your browser will open a window where you input that code. Complete the wizard by authorizing Github Copilot.
Enable/Disable Manually
you have these commands to turn the suggestions on/off
:Copilot enable
:Copilot disable
:Copilot status
About the author
- Markdown + Vim fan. Love sharing knowledge with the community Dev-san, gambare! ᕙ( •̀ ᗜ •́ )👍
Comments
Join the discussionNo comments yet. Be the first to comment.
vim
this series includes articles related to vim, the efficient editor that lets you work faster and comfortably.






