1

If one installs the Github Copilot software for the Vim editor, it enables the co-pilot by default, which could be seen as a privacy issue.

I want to disable the co-pilot by default and only enable it manually via :Copilot enable in the editor when needed.

How may I do that?

2 Answers 2

2

The co-pilot can be globally disabled with :Copilot disable. This command may be executed automatically from the vimrc file (~/.vimrc or ~/.vim/vimrc or $XDG_CONFIG_HOME/vim/vimrc) using an autocmd command like so:

autocmd VimEnter * Copilot disable

The VimEnter event is triggered "after doing all the startup stuff". The pattern * matches all filenames, so it always applies.

It is then a matter of running the command :Copilot enable whenever one wants to have inline suggestions from the co-pilot again.

1

I believe the option you're looking for is g:copilot_filetypes:

g:copilot_filetypes     A dictionary mapping file types to their enabled
                        status.  Most file types are enabled by default, so
                        generally this is used for opting out.
>
                        let g:copilot_filetypes = {
                              \ 'xml': v:false,
                              \ }
<
                        Disabling all file types can be done by setting the
                        special key "*".  File types can then be turned back
                        on individually.
>
                        let g:copilot_filetypes = {
                              \ '*': v:false,
                              \ 'python': v:true,
                              \ }

So add to your vimrc:

let g:copilot_filetypes = { '*': v:false }

And then enable it when needed.

7
  • For the "enable it when needed" bit, one would need to manually type in the corresponding command to enable the co-pilot for all file types or the current buffer's file type (which you would have to query with :set ft first). This would IMHO be more cumbersome than just giving the command :Copilot enable. It would also render one's setup of Copilot-enabled file types useless. Commented Sep 1, 2024 at 7:45
  • @Kusalananda are you saying that with this config, just doing :Copilot enable doesn't enable copilot? Commented Sep 1, 2024 at 7:56
  • Also there's the buffer-local b:copilot_enabled described right below this option which should be more convenient than looking up the buffer's file type Commented Sep 1, 2024 at 7:59
  • Exactly. With your suggestion, the co-pilot would still be disabled based on the file type of the current buffer matching that * pattern, even if you do :Copilot enable (it does not reset the g:copilot_filetypes structure). Commented Sep 1, 2024 at 10:05
  • And if you do let b:copilot_enabled = v:true in the buffer in which you want to enable it? Commented Sep 1, 2024 at 10:18

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.