*copilot.txt*  GitHub Copilot - Your AI pair programmer

GETTING STARTED                                 *copilot*

Invoke `:Copilot setup` to authenticate and enable GitHub Copilot.

Suggestions are displayed inline and can be accepted by pressing <Tab>.  If
inline suggestions do not appear to be working, invoke `:Copilot status` to
verify Copilot is enabled and not experiencing any issues.

COMMANDS                                        *:Copilot*

                                                *:Copilot_disable*
:Copilot disable        Globally disable GitHub Copilot inline suggestions.

                                                *:Copilot_enable*
:Copilot enable         Re-enable GitHub Copilot after :Copilot disable.

                                                *:Copilot_setup*
:Copilot setup          Authenticate and enable GitHub Copilot.

                                                *:Copilot_signout*
:Copilot signout        Sign out of GitHub Copilot.

                                                *:Copilot_status*
:Copilot status         Check if GitHub Copilot is operational for the current
                        buffer and report on any issues.

                                                *:Copilot_model*
:Copilot model          If a preview or other alternate model for completions
                        is available, provides an interactive interface for
                        enabling it for the rest of the current Vim/Neovim
                        session.  Note that typically the number of available
                        completions models is one, rendering this command
                        inert.

                                                *:Copilot_panel*
:Copilot panel          Open a window with up to 10 completions for the
                        current buffer.  Use <CR> to accept a completion.
                        Maps are also provided for [[ and ]] to jump from
                        completion to completion.

                                                *:Copilot_version*
:Copilot version        Show version information.

                                                *:Copilot_upgrade*
:Copilot upgrade        Upgrade the Copilot Language Server to the latest
                        version with `npx`.  This works by temporarily setting
                        |g:copilot_version| to "latest" and restarting.

OPTIONS                                         *copilot-options*

g:copilot_version       Specify a version constraint passed to `npx` when
                        running the Copilot Language Server.  By default, this
                        is a minor version constraint like "^1.400.0" that
                        matches a known good version but allows minor version
                        updates.  You can pin this to a specific version, or
                        use the special value of "latest" which causes `npx`
                        to always fetch the latest version at startup.
>
                        let g:copilot_version = 'latest'
<
                        As a special case, setting this to v:false will
                        disable the use of `npx` and use a static version of
                        the language server embedded in the plugin.
>
                        let g:copilot_version = v:false
<
                                                *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,
                              \ }
<
                                                *b:copilot_enabled*
b:copilot_enabled       Set to v:false to disable GitHub Copilot for the
                        current buffer.  Or set to v:true to force enabling
                        it, overriding g:copilot_filetypes.

                                                *g:copilot_node_command*
g:copilot_node_command  Tell Copilot what `node` binary to use with
                        g:copilot_node_command. This is useful if the `node`
                        in your PATH is an unsupported version.
>
                        let g:copilot_node_command =
                              \ "~/.nodenv/versions/18.18.0/bin/node"
<
                                                *g:copilot_enterprise_uri*
g:copilot_enterprise_uri
                        If you are using GitHub Copilot Enterprise, set this
                        to the URI of your GitHub Enterprise instance.
>
                        let g:copilot_enterprise_uri = 'https://DOMAIN.ghe.com'
<
                                                *g:copilot_proxy*
g:copilot_proxy         Tell Copilot what proxy server to use.
>
                        let g:copilot_proxy = 'http://localhost:3128'
<
                        If this is not set, Copilot will use the value of
                        environment variables like $HTTPS_PROXY.

                                                *g:copilot_proxy_strict_ssl*
g:copilot_proxy_strict_ssl
                        Corporate proxies sometimes use a man-in-the-middle
                        SSL certificate which is incompatible with GitHub
                        Copilot.  To work around this, SSL certificate
                        verification can be disabled:
>
                        let g:copilot_proxy_strict_ssl = v:false
<
                        You can also tell Node.js to disable SSL verification
                        by setting the $NODE_TLS_REJECT_UNAUTHORIZED
                        environment variable to "0".

                                                *g:copilot_workspace_folders*
g:copilot_workspace_folders
                        A list of "workspace folders" or project roots that
                        Copilot may use to improve the quality of suggestions.
>
                        let g:copilot_workspace_folders =
                               \ ["~/Projects/myproject"]
<
                        You can also set b:workspace_folder for an individual
                        buffer and newly seen values will be added
                        automatically.

MAPS                                            *copilot-maps*

                                                *copilot-i_<Tab>*
Copilot.vim uses <Tab> to accept the current suggestion.  If you have an
existing <Tab> map, that will be used as the fallback when no suggestion is
displayed.

                                                *copilot#Accept()*
If you'd rather use a key that isn't <Tab>, define an <expr> map that calls
copilot#Accept().  Here's an example with CTRL-J:
>
        imap <silent><script><expr> <C-J> copilot#Accept("\<CR>")
        let g:copilot_no_tab_map = v:true
<
Lua version:
>
        vim.keymap.set('i', '<C-J>', 'copilot#Accept("\\<CR>")', {
          expr = true,
          replace_keycodes = false
        })
        vim.g.copilot_no_tab_map = true
<
The argument to copilot#Accept() is the fallback for when no suggestion is
displayed.  In this example, a regular carriage return is used.  If no
fallback is desired, use an argument of "" (an empty string).

Other Maps ~

Note that M- (a.k.a. meta or alt) maps are highly dependent on your terminal
to function correctly and may be unsupported with your setup.  As an
alternative, you can create your own versions that invoke the <Plug> maps
instead.  Here's an example that maps CTRL-L to accept one word of the
current suggestion:
>
        imap <C-L> <Plug>(copilot-accept-word)
<
Lua version:
>
        vim.keymap.set('i', '<C-L>', '<Plug>(copilot-accept-word)')
<
                                                *copilot-i_CTRL-]*
<C-]>                   Dismiss the current suggestion.
<Plug>(copilot-dismiss)

                                                *copilot-i_ALT-]*
<M-]>                   Cycle to the next suggestion, if one is available.
<Plug>(copilot-next)

                                                *copilot-i_ALT-[*
<M-[>                   Cycle to the previous suggestion.
<Plug>(copilot-previous)

                                                *copilot-i_ALT-\*
<M-\>                   Explicitly request a suggestion, even if Copilot
<Plug>(copilot-suggest) is disabled.

                                                *copilot-i_ALT-Right*
<M-Right>               Accept the next word of the current suggestion.
<Plug>(copilot-accept-word)

                                                *copilot-i_ALT-CTRL-Right*

<M-C-Right>             Accept the next line of the current suggestion.
<Plug>(copilot-accept-line)

SYNTAX HIGHLIGHTING                             *copilot-highlighting*

Inline suggestions are highlighted using the CopilotSuggestion group,
defaulting to a medium gray.  The best place to override this is with
a |ColorScheme| autocommand:
>
        autocmd ColorScheme solarized
              \ highlight CopilotSuggestion guifg=#555555 ctermfg=8
<
Lua version:
>
        vim.api.nvim_create_autocmd('ColorScheme', {
          pattern = 'solarized',
          -- group = ...,
          callback = function()
            vim.api.nvim_set_hl(0, 'CopilotSuggestion', {
              fg = '#555555',
              ctermfg = 8,
              force = true
            })
          end
        })
<
 vim:tw=78:et:ft=help:norl:
