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 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 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
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://api.github.com/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://api.github.com/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"
35 changes: 35 additions & 0 deletions .github/workflows/vimdocgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Auto Generate Vimdoc
on:
push:
branches: [main]
paths:
- README.md
- .github/workflows/vimdocgen.yml
workflow_dispatch:

permissions:
contents: 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
70 changes: 64 additions & 6 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 Down Expand Up @@ -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.
816 changes: 407 additions & 409 deletions copilot/js/main.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions copilot/js/main.js.map

Large diffs are not rendered by default.

File renamed without changes.
Loading