AI Completion In The Shell

From Rest of What I Know
Revision as of 23:27, 10 April 2024 by Roshan (talk | contribs) (Created page with "LLMs are fantastic for programming. I use ChatGPT, Claude, and Copilot routinely. One place where I didn't have a good workflow was my terminal, but [https://x.com/arjie/status/1575201117595926530 I found a way that I find quite pleasant and I've been using it for a few months]. thumb|alt=A screen recording of Copilot in Neovim helping with an AWS question|See how easy it is == Steps == 1. Install <code>neovim</code> 2. Install Copilot on...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

LLMs are fantastic for programming. I use ChatGPT, Claude, and Copilot routinely. One place where I didn't have a good workflow was my terminal, but I found a way that I find quite pleasant and I've been using it for a few months.

See how easy it is

Steps

1. Install neovim

2. Install Copilot on it using copilot.vim

3. Set EDITOR=nvim

4. Use Ctrl-X Ctrl-E at your command-prompt to enter your Neovim-enabled Copilot

Additional Tips

Here's my ~/.config/nvim/init.vim for the relevant bits. I use vim-plug which I've found quite useful to manage vim plugins.

call plug#begin()
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
  Plug 'github/copilot.vim'
call plug#end()

" Deoplete
let g:deoplete#enable_at_startup = 1
"" <TAB>: completion.
inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB>  pumvisible() ? "\<C-p>" : "\<TAB>"

I also use zsh with oh-my-zsh and starship.rs so entering and leaving this is quite easy and pleasant. I can type some at the command-prompt and then go back to nvim and so on because it will expand things like !! and so on.