Skip to content

[pull] master from zbirenbaum:master #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 87 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
174cc54
docs: fix typos and add table of contents
MuntasirSZN Apr 11, 2025
1f87b56
feat: faq section
MuntasirSZN Apr 11, 2025
0ebc217
feat(ci): make version updates automatic in util.lua
MuntasirSZN Apr 11, 2025
87f298a
docs: add a disclamer on the Certificate Parsing solution
AntoineGS Apr 11, 2025
9481fc7
feat: add undocumented callback, currently used for testing
AntoineGS Apr 10, 2025
e99043e
test: cleanup tests, remove sleeps in favor of callbacks, ensure green
AntoineGS Apr 10, 2025
9a5960a
chore: fix .gitignore of deps and remove luarc
AntoineGS Apr 11, 2025
54b8e5b
refactor: renormalize EOL of Lua files to LF
AntoineGS Apr 11, 2025
672a435
ci: update makefile with osv
AntoineGS Apr 11, 2025
41c3931
tests: use built-in blocking feature of osv instead of callback
AntoineGS Apr 11, 2025
18029c3
docs: fix Caution tag
AntoineGS Apr 11, 2025
0a75029
docs: encapsulate default config in <details> tags
AntoineGS Apr 11, 2025
3f106ff
fix(ci): variable changes persistance
MuntasirSZN Apr 11, 2025
35a99d4
fix(ci): ensure util.lua is committed, split util.lua job
AntoineGS Apr 12, 2025
39e8b53
ci: upgrade workflow actions
AntoineGS Apr 12, 2025
ccb1336
ci: only run copilot update workflow on main repo (not forks)
AntoineGS Apr 12, 2025
02ff5df
ci: initial release for automated tests
AntoineGS Apr 11, 2025
c62a2a7
feat: update to latest Copilot LSP
github-actions[bot] Apr 12, 2025
891aee9
fix: incorrectly used 0.11 instead of 0.10 as cutoff
AntoineGS Apr 13, 2025
f4d5759
docs: typo
MuntasirSZN Apr 12, 2025
0014e3f
feat: add vimdoc
MuntasirSZN Apr 12, 2025
0dc1b00
ci: automate dependency updates with Dependabot
MuntasirSZN Apr 12, 2025
962cf8b
fix: fix more typos, use pull request action instead of pushing directly
MuntasirSZN Apr 14, 2025
d712de3
chore(deps): bump actions/checkout from 2 to 4
dependabot[bot] Apr 14, 2025
e3768e3
feat: support for binary file accessible by PATH
AntoineGS Apr 14, 2025
29b1676
refactor: add .gitkeeps and remove dist folder
AntoineGS Apr 15, 2025
ccd34fa
refactor: typos
AntoineGS Apr 15, 2025
cf6cb4f
fix: URI conversion for panel would assume file:// prefix
AntoineGS Apr 15, 2025
9822eaf
ci: run vimdocgen on workflow dispatch
MuntasirSZN Apr 15, 2025
b65903d
ci: remove folder creation
AntoineGS Apr 15, 2025
353853c
refactor: eliminate deprecated warnings (#455)
phanen Apr 15, 2025
1b319db
ci: use copilot as project name and disable toc
MuntasirSZN Apr 15, 2025
4e8637c
docs: add vimdoc
MuntasirSZN Apr 15, 2025
49922c9
ci: remove reviewers, fix type in 'commit-message'
AntoineGS Apr 16, 2025
25791dd
ci: allow running job manually
AntoineGS Apr 16, 2025
0b43549
Revert "refactor: eliminate deprecated warnings (#455)"
AntoineGS Apr 16, 2025
935ad69
feat: update to latest Copilot LSP
github-actions[bot] Apr 18, 2025
ec62fd6
feat: leverage virt_text_inline to improve inline suggestions (#465)
AntoineGS Apr 18, 2025
b3988bb
refactor: eliminate deprecated warnings (2nd try) (#464)
phanen Apr 18, 2025
4d4840b
fix: accidentally committed print statements
AntoineGS Apr 19, 2025
dc579f9
fix: broken :Copilot version command
AntoineGS Apr 20, 2025
c0d1824
fix: prevent partial accepts from triggering a new suggestion (#469)
AntoineGS Apr 22, 2025
089ec63
fix: ensure encoding is utf-# (#470)
AntoineGS Apr 22, 2025
fc015b7
fix: resolve stutter when typing over virtual text
AntoineGS Apr 23, 2025
e5b65bb
fix: typo in error message
AntoineGS Apr 24, 2025
2f50ec4
fix: unable to accept panel suggestion (buffer was closed error)
AntoineGS Apr 24, 2025
aef4c9e
test: fix panel test on linux
AntoineGS Apr 25, 2025
a5c390f
feat: update to latest Copilot LSP
github-actions[bot] Apr 25, 2025
ce23086
fix: highlighting of suggestions may become "MatchParen" under certai…
tadashi-aikawa Apr 29, 2025
7ba7386
feat: update to latest Copilot LSP
github-actions[bot] May 6, 2025
2fe34db
doc: update README.md
AntoineGS May 8, 2025
0929c92
feat: update to latest Copilot LSP
github-actions[bot] May 15, 2025
1127cf7
ci: use of correct branch for vimdoc PR generation
AntoineGS May 20, 2025
9ae1021
ci: allow PR creation for vimdocgen
AntoineGS May 20, 2025
642d6e9
docs: update vimdocs
github-actions[bot] May 20, 2025
96e1bb1
fix: issue on Linux and URIs
AntoineGS May 20, 2025
a620a5a
feat: update to latest Copilot LSP
github-actions[bot] May 22, 2025
5f726c8
feat: update to latest Copilot LSP (#493)
github-actions[bot] May 28, 2025
c1bb86a
feat: update to latest Copilot LSP
github-actions[bot] Jun 5, 2025
46f4b7d
feat: update to latest Copilot LSP
github-actions[bot] Jun 27, 2025
b0ffa35
fix: call should_attach on sign_in (#509)
powerman Jul 8, 2025
f26345d
fix: call lsp.start after loading buffer (#508)
powerman Jul 8, 2025
3680beb
feat: update to latest Copilot LSP
github-actions[bot] Jul 8, 2025
f7e2dc7
feat: update to latest Copilot LSP
github-actions[bot] Jul 16, 2025
14bf786
perf: use vim.loop.os_uname() for is_arm (#513)
samirettali Jul 16, 2025
ef6a407
test: update deprecating options
AntoineGS Jul 16, 2025
64422b7
refactor: remove panel horizontal and vertical positions as they have…
proofer Jul 25, 2025
19aacfa
Merge remote-tracking branch 'origin/master'
AntoineGS Jul 25, 2025
4958fb9
feat: update to latest Copilot LSP
github-actions[bot] Jul 25, 2025
d921204
fix: multiple buffers opened cause incorrect should_attach logic (#521)
AntoineGS Jul 28, 2025
8c4b70d
feat: expose is_authenticated() helper and add checkhealth support (#…
cosmicbuffalo Jul 28, 2025
0e1348e
feat: update to latest Copilot LSP
github-actions[bot] Jul 28, 2025
2d7261d
Revert "fix: multiple buffers opened cause incorrect should_attach lo…
AntoineGS Jul 28, 2025
2c3d15c
fix: multiple buffers opened cause incorrect should_attach logic
AntoineGS Jul 29, 2025
045daa5
fix: prevent calling buf_attach_client without a client id
AntoineGS Jul 29, 2025
81cba6d
fix: fail to start when not using lazy loading of plugin
AntoineGS Jul 29, 2025
096c8f6
test: change wait delay
AntoineGS Jul 29, 2025
1c2e65e
fix: ensure buffer is not attached on LSP start as it is long-lived r…
AntoineGS Jul 29, 2025
55e4302
test: add test for filetype exclusion
AntoineGS Jul 29, 2025
f22d869
refactor: improve error handling when node --version does not output …
AntoineGS Jul 31, 2025
60508f9
fix: error message when node --version returns nothing
AntoineGS Aug 1, 2025
b6fe6bb
feat: update to latest Copilot LSP
github-actions[bot] Aug 1, 2025
4c98663
feat: add log file path to :checkhealth
AntoineGS Aug 1, 2025
6ea6bcc
test: add test for lazy loading = false
AntoineGS Aug 1, 2025
6fa90e6
fix: only clear autocmd group if it was created
AntoineGS Aug 1, 2025
5bbc107
fix: ensure logger is set up prior to starting the LSP
AntoineGS Aug 1, 2025
0f2fd38
refactor: log configuration before doing anything that could fail
AntoineGS Aug 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/copilot/dist/** -whitespace -diff
/dist/** -whitespace -diff
*.lua eol=lf
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
44 changes: 44 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Tests

on: [push, pull_request]

jobs:
unit_tests:
name: unit tests
if: github.repository == 'AntoineGS/copilot.lua'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-latest, windows-2025]
rev: [nightly, v0.10.4, v0.11.0]
include:
- os: ubuntu-24.04
install-rg: sudo apt-get update && sudo apt-get install -y nodejs curl
- os: ubuntu-24.04-arm
install-rg: sudo apt-get update && sudo apt-get install -y nodejs curl
- os: macos-latest
install-rg: brew update && brew install node curl
- os: windows-2025
install-rg: choco install nodejs-lts curl

steps:
- uses: actions/checkout@v4

- uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.rev }}

- name: Prepare
run: |
${{ matrix.install-rg }}
git clone --filter=blob:none https://github.com/echasnovski/mini.nvim deps/mini.nvim
mv ./tests/env.lua.ci ./tests/env.lua

- name: Run tests
env:
GH_COPILOT_TOKEN: ${{ secrets.GH_COPILOT_TOKEN }}
run: |
nvim --version
make test
15 changes: 11 additions & 4 deletions .github/workflows/update-copilot-nodejs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ on:
- cron: "0 0 * * *"
push:
branches: [master]
workflow_dispatch:

jobs:
update_copilot_lsp:
runs-on: ubuntu-latest
name: Update Copilot LSP
if: github.repository == 'zbirenbaum/copilot.lua'
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Create directory
run: |
Expand All @@ -22,18 +24,23 @@ jobs:
run: |
curl -s https://github.com/api/repos/github/copilot-language-server-release/releases/latest | grep "browser_download_url.*copilot-language-server-js-.*zip" | cut -d : -f 2,3 | tr -d \" | wget -vi -

- name: Update version in util.lua
run: |
COPILOT_LATEST_RELEASE_VER=$(curl -s https://github.com/api/repos/github/copilot-language-server-release/releases | jq -r '.[0].tag_name') && sed -i.bak -E "s/(version = \")[^\"]+(\",)/\1$COPILOT_LATEST_RELEASE_VER\2/" "lua/copilot/util.lua" && rm lua/copilot/util.lua.bak

- name: Unzip LSP
run: |
unzip -o copilot-language-server-js-*.zip -d copilot/js
rm copilot-language-server-js-*.zip

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v7
with:
add-paths: "copilot/js/*"
add-paths: |
copilot/js/*
lua/copilot/util.lua
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
base: master
branch: create-pull-request/update-copilot-lsp
commit-message: "feat: update to latest Copilot LSP"
reviewers: MunifTanjim,zbirenbaum,AntoineGS
title: "Update Copilot LSP"
36 changes: 36 additions & 0 deletions .github/workflows/vimdocgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Auto Generate Vimdoc
on:
push:
branches: [master]
paths:
- README.md
- .github/workflows/vimdocgen.yml
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
docs:
runs-on: ubuntu-latest
name: Convert Markdown to Vimdoc
steps:
- uses: actions/checkout@v4
- uses: kdheepak/panvimdoc@main
with:
vimdoc: "copilot"
version: "NVIM v0.11.0"
description: "Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot"
titledatepattern: "%d %B, %Y"
toc: false
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
add-paths: |
doc/*
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
base: master
branch: create-pull-request/autogenerate-vimdoc
commit-message: "docs: update vimdocs"
title: "Update Vimdocs"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tests/logs
tests/env.lua
tests/deps
deps/
5 changes: 0 additions & 5 deletions .luarc.json

This file was deleted.

7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Run all test files
# test: deps/mini.nvim
test:
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run()"
nvim --headless --noplugin -u ./tests/scripts/minimal_init.lua -c "lua MiniTest.run()"

# Run test from file at `$FILE` environment variable
test_file: deps/mini.nvim
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run_file('$(FILE)')"
nvim --headless --noplugin -u ./tests/scripts/minimal_init.lua -c "lua MiniTest.run_file('$(FILE)')"

# Download 'mini.nvim' to use its 'mini.test' testing module
# deps/mini.nvim:
# @mkdir deps
# git clone --filter=blob:none https://github.com/echasnovski/mini.nvim $@
# git clone --filter=blob:none https://github.com/echasnovski/mini.nvim deps/mini.nvim
# git clone https://github.com/jbyuki/one-small-step-for-vimkind deps/osv
74 changes: 66 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@ As lua is far more efficient and makes things easier to integrate with modern pl

</details>

## Table Of Contents

<!--toc:start-->

- [Requirements](#requirements)
- [Install](#install)
- [Authentication](#authentication)
- [Authentication with Alternate GitHub Instances](#authentication-with-alternate-github-instances)
- [Setup and Configuration](#setup-and-configuration)
- [panel](#panel)
- [suggestion](#suggestion)
- [filetypes](#filetypes)
- [logger](#logger)
- [copilot_node_command](#copilot_node_command)
- [server_opts_overrides](#server_opts_overrides)
- [workspace_folders](#workspace_folders)
- [root_dir](#root_dir)
- [should_attach](#should_attach)
- [server](#server)
- [Commands](#commands)
- [Integrations](#integrations)
- [FAQ](#faq)

<!--toc:end-->

## Requirements

- Curl
Expand Down Expand Up @@ -76,7 +101,8 @@ use {
}
```

The following is the default configuration:
<details>
<summary>Default configuration</summary>

```lua
require('copilot').setup({
Expand All @@ -91,7 +117,7 @@ require('copilot').setup({
open = "<M-CR>"
},
layout = {
position = "bottom", -- | top | left | right | horizontal | vertical
position = "bottom", -- | top | left | right | bottom |
ratio = 0.4
},
},
Expand Down Expand Up @@ -132,7 +158,7 @@ require('copilot').setup({
},
copilot_node_command = 'node', -- Node.js version must be > 20
workspace_folders = {},
copilot_model = "", -- Current LSP default is gpt-35-turbo, supports gpt-4o-copilot
copilot_model = "",
root_dir = function()
return vim.fs.dirname(vim.fs.find(".git", { upward = true })[1])
end,
Expand All @@ -157,6 +183,8 @@ require('copilot').setup({
})
```

</details>

### panel

Panel can be used to preview suggestions in a split window. You can run the
Expand Down Expand Up @@ -297,7 +325,7 @@ vim.log = {

- `off`
- `messages` which will output the LSP messages
- `verbose` which adds additonal information to the message.
- `verbose` which adds additional information to the message.

When `trace_lsp_progress` is true, LSP progress messages (`$/progress`) will also be logged.
When `log_lsp_messages` is true, LSP log messages (`window/logMessage`) events will be logged.
Expand All @@ -318,7 +346,7 @@ copilot_node_command = vim.fn.expand("$HOME") .. "/.config/nvm/versions/node/v20

Override copilot lsp client settings. The `settings` field is where you can set the values of the options defined in [SettingsOpts.md](./SettingsOpts.md).
These options are specific to the copilot lsp and can be used to customize its behavior. Ensure that the name field is not overridden as is is used for
efficiency reasons in numerous checks to verify copilot is actually running. See `:h vim.lsp.start_client` for list of options.
efficiency reasons in numerous checks to verify copilot is actually running. See `:h vim.lsp.start` for list of options.

Example:

Expand All @@ -339,7 +367,7 @@ require("copilot").setup {
### workspace_folders

Workspace folders improve Copilot's suggestions.
By default, the root_dir is used as a wokspace_folder.
By default, the root_dir is used as a workspace_folder.

Additional folders can be added through the configuration as such:

Expand Down Expand Up @@ -380,11 +408,13 @@ require("copilot").setup {

### server

> [!CAUTION] > `"binary"` mode is still very much experimental, please report any issues you encounter.
> [!CAUTION]
> `"binary"` mode is still very much experimental, please report any issues you encounter.

`type` can be either `"nodejs"` or `"binary"`. The binary version will be downloaded if used.

`custom_server_filepath` is used to specify the path of either the path (filename included) of the `js` file if using `"nodejs"` or the path to the binary if using `"binary"`.
`custom_server_filepath` is used to specify the server path (filename included) of either the `js` file if using `"nodejs"` or to the binary if using `"binary"`.
The filename on its own can also be set if accessible through your PATH.
When using `"binary"`, the download process will be disabled and the binary will be used directly.
example:

Expand All @@ -409,3 +439,31 @@ The `copilot.api` module can be used to build integrations on top of `copilot.lu
- [giuxtaposition/blink-cmp-copilot](https://github.com/giuxtaposition/blink-cmp-copilot): Integration with [`blink.cmp`](https://github.com/Saghen/blink.cmp).
- [fang2hou/blink-copilot](https://github.com/fang2hou/blink-copilot): Integration with [`blink.cmp`](https://github.com/Saghen/blink.cmp), with some differences.
- [AndreM222/copilot-lualine](https://github.com/AndreM222/copilot-lualine): Integration with [`lualine.nvim`](https://github.com/nvim-lualine/lualine.nvim).

## FAQ

> Certificate Parsing Error

This is an issue with the copilot lsp itself as described in [this discussion](https://github.com/orgs/community/discussions/136273#discussioncomment-10433527). Please update the plugin to the latest version to solve this issue.
If updating does not help, some users have reported that updating the `/usr/bin/update-ca-trust` and removing the --comment option from the trust extract commands solves the issue.
However this has not been verified by the author of this plugin and may have unintended consequences so thread with care.

> Multiple offset encodings warning

As discussed in #247, the problem arises because two or more clients are using different offset encodings. To solve this, in lspconfig:

```lua
local capabilities = vim.lsp.protocol.make_client_capabilities() -- Get The capabilities
capabilities.general.positionEncodings = { "utf-16" } -- Set the offset encoding, see `:h vim.lsp.start` for more info
require("lspconfig")[server].setup({ capabilities = capabilities }) -- Setup the server
```

Set the same for copilot in `server_opts_overrides`:

```lua
server_opts_overrides = {
offset_encoding = "utf-16" -- Set the offset encoding same as above, see `:h vim.lsp.start` for more info
}
```

Refer to your plugins documentation for changes.
26 changes: 24 additions & 2 deletions copilot/js/api/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ export interface ContextProvider<T extends SupportedContextItem> {
selector: DocumentSelector;
resolver: ContextResolver<T>;
}

export type ResolveOnTimeoutResult<T> = T | readonly T[];
export type ResolveResult<T> = Promise<T> | Promise<readonly T[]> | AsyncIterable<T>;

export interface ContextResolver<T extends SupportedContextItem> {
resolve(request: ResolveRequest, token: CancellationToken): Promise<T> | Promise<T[]> | AsyncIterable<T>;
resolve(request: ResolveRequest, token: CancellationToken): ResolveResult<T>;
// Optional method to be invoked if the request timed out. This requests additional context items.
resolveOnTimeout?(request: ResolveRequest): ResolveOnTimeoutResult<T> | undefined;
}

/**
Expand Down Expand Up @@ -86,20 +92,29 @@ export type ContextUsageStatistics = {
usageDetails?: ContextItemUsageDetails[];
};

export type ProposedTextEdit = TextEdit & {
positionAfterEdit: Position;
// Indicates whether the edit is suggested by the IDE. Otherwise it's assumed to be speculative
source?: 'selectedCompletionInfo';
};

export interface DocumentContext {
uri: DocumentUri;
languageId: string;
version: number;
// Position and offset are relative to the provided version of the document.
// The position after an edit is applied is found in ProposedTextEdit.positionAfterEdit.
/**
* @deprecated Use `position` instead.
*/
offset: number;
position: Position;
proposedEdits?: TextEdit[];
proposedEdits?: ProposedTextEdit[];
}
export interface ResolveRequest {
// A unique ID to correlate the request with the completion request.
completionId: string;
opportunityId: string;
documentContext: DocumentContext;

activeExperiments: Map<string, string | number | boolean | string[]>;
Expand All @@ -109,9 +124,16 @@ export interface ResolveRequest {
* After the time budget runs out, the request will be cancelled via the CancellationToken.
* Providers can use this value as a hint when computing context. Providers should expect the
* request to be cancelled once the time budget runs out.
*
* @deprecated Use `timeoutEnd` instead.
*/
timeBudget: number;

/**
* Unix timestamp representing the exact time the request will be cancelled via the CancellationToken.
*/
timeoutEnd: number;

/**
* Various statistics about the last completion request. This can be used by the context provider
* to make decisions about what context to provide for the current call.
Expand Down
Binary file added copilot/js/bin/darwin/arm64/rg
Binary file not shown.
Binary file added copilot/js/bin/darwin/x64/rg
Binary file not shown.
Binary file added copilot/js/bin/linux/arm64/rg
Binary file not shown.
Binary file added copilot/js/bin/linux/x64/rg
Binary file not shown.
Binary file added copilot/js/bin/win32/arm64/rg.exe
Binary file not shown.
Binary file added copilot/js/bin/win32/x64/rg.exe
Binary file not shown.
Loading