{"id":13476432,"url":"https://github.com/zbirenbaum/copilot-cmp","last_synced_at":"2025-05-14T18:02:39.084Z","repository":{"id":37438293,"uuid":"477184708","full_name":"zbirenbaum/copilot-cmp","owner":"zbirenbaum","description":"Lua plugin to turn github copilot into a cmp source","archived":false,"fork":false,"pushed_at":"2024-12-11T19:58:19.000Z","size":87,"stargazers_count":1279,"open_issues_count":23,"forks_count":47,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-14T18:02:31.212Z","etag":null,"topics":["copilot","github-copilot","lua","neovim","nvim-cmp"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zbirenbaum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-02T22:24:10.000Z","updated_at":"2025-05-12T19:21:26.000Z","dependencies_parsed_at":"2024-06-15T01:38:43.851Z","dependency_job_id":"f16a28cc-47c5-4a83-908e-fd95589e4a22","html_url":"https://github.com/zbirenbaum/copilot-cmp","commit_stats":{"total_commits":90,"total_committers":13,"mean_commits":6.923076923076923,"dds":0.1333333333333333,"last_synced_commit":"15fc12af3d0109fa76b60b5cffa1373697e261d1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbirenbaum%2Fcopilot-cmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbirenbaum%2Fcopilot-cmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbirenbaum%2Fcopilot-cmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbirenbaum%2Fcopilot-cmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zbirenbaum","download_url":"https://codeload.github.com/zbirenbaum/copilot-cmp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198452,"owners_count":22030964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["copilot","github-copilot","lua","neovim","nvim-cmp"],"created_at":"2024-07-31T16:01:30.231Z","updated_at":"2025-05-14T18:02:38.876Z","avatar_url":"https://github.com/zbirenbaum.png","language":"Lua","readme":"# copilot-cmp\n\nThis repository transforms https://github.com/zbirenbaum/copilot.lua into a cmp source.\n\nCopilot suggestions will automatically be loaded into your cmp menu as snippets and display their full contents when a copilot suggestion is hovered.\n\n![copilot-cmp](https://user-images.githubusercontent.com/32016110/173933674-9ad85a5a-5ad7-41cd-9fcc-f5a698cc88ae.png)\n\n\n## Setup\n\nIf you already have copilot.lua installed, you can install this plugin with packer as you would any other with the following code:\n\n### Install\n\n#### Lazy\n```lua\n{\n  \"zbirenbaum/copilot-cmp\",\n  config = function ()\n    require(\"copilot_cmp\").setup()\n  end\n}\n\n```\n\n#### Packer\n```lua\nuse {\n  \"zbirenbaum/copilot-cmp\",\n  after = { \"copilot.lua\" },\n  config = function ()\n    require(\"copilot_cmp\").setup()\n  end\n}\n```\n\nIf you do not have copilot.lua installed, go to https://github.com/zbirenbaum/copilot.lua and follow the instructions there before installing this one\n\nIt is recommended to disable copilot.lua's suggestion and panel modules, as they can interfere with completions properly appearing in copilot-cmp. To do so, simply place the following in your copilot.lua config:\n```lua\nrequire(\"copilot\").setup({\n  suggestion = { enabled = false },\n  panel = { enabled = false },\n})\n```\n\n### Configuration:\n\n#### nvim-cmp:\n\n##### Source Definition\n\nTo link cmp with this source, simply go into your cmp configuration file and include `{ name = \"copilot\" }` under your sources\n\nHere is an example of what it should look like:\n\n```lua\ncmp.setup {\n  ...\n  sources = {\n    -- Copilot Source\n    { name = \"copilot\", group_index = 2 },\n    -- Other Sources\n    { name = \"nvim_lsp\", group_index = 2 },\n    { name = \"path\", group_index = 2 },\n    { name = \"luasnip\", group_index = 2 },\n  },\n  ...\n}\n```\n\n##### Highlighting \u0026 Icon\n\nCopilot's cmp source now has a builtin highlight group `CmpItemKindCopilot`. To add an icon to copilot for lspkind, simply add copilot to your lspkind symbol map.\n\n```lua\n-- lspkind.lua\nlocal lspkind = require(\"lspkind\")\nlspkind.init({\n  symbol_map = {\n    Copilot = \"\",\n  },\n})\n\nvim.api.nvim_set_hl(0, \"CmpItemKindCopilot\", {fg =\"#6CC644\"})\n```\n\nAlternatively, you can add Copilot to the lspkind `symbol_map` within the cmp format function.\n\n```lua\n-- cmp.lua\ncmp.setup {\n  ...\n  formatting = {\n    format = lspkind.cmp_format({\n      mode = \"symbol\",\n      max_width = 50,\n      symbol_map = { Copilot = \"\" }\n    })\n  }\n  ...\n}\n```\n\nIf you do not use lspkind, simply add the custom icon however you normally handle `kind` formatting and it will integrate as if it was any other normal lsp completion kind.\n\n##### Tab Completion Configuration (Highly Recommended)\nUnlike other completion sources, copilot can use other lines above or below an empty line to provide a completion. This can cause problematic for individuals that select menu entries with `\u003cTAB\u003e`. This behavior is configurable via cmp's config and the following code will make it so that the menu still appears normally, but tab will fallback to indenting unless a non-whitespace character has actually been typed.\n\n```lua\nlocal has_words_before = function()\n  if vim.api.nvim_buf_get_option(0, \"buftype\") == \"prompt\" then return false end\n  local line, col = unpack(vim.api.nvim_win_get_cursor(0))\n  return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match(\"^%s*$\") == nil\nend\ncmp.setup({\n  mapping = {\n    [\"\u003cTab\u003e\"] = vim.schedule_wrap(function(fallback)\n      if cmp.visible() and has_words_before() then\n        cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })\n      else\n        fallback()\n      end\n    end),\n  },\n})\n```\n\n##### Comparators\n\nOne custom comparitor for sorting cmp entries is provided: `prioritize`. The `prioritize` comparitor causes copilot entries to appear higher in the cmp menu. It is recommended keeping priority weight at 2, or placing the `exact` comparitor above copilot so that better lsp matches are not stuck below poor copilot matches.\n\nExample:\n\n```lua\ncmp.setup {\n  ...\n  sorting = {\n    priority_weight = 2,\n    comparators = {\n      require(\"copilot_cmp.comparators\").prioritize,\n\n      -- Below is the default comparitor list and order for nvim-cmp\n      cmp.config.compare.offset,\n      -- cmp.config.compare.scopes, --this is commented in nvim-cmp too\n      cmp.config.compare.exact,\n      cmp.config.compare.score,\n      cmp.config.compare.recently_used,\n      cmp.config.compare.locality,\n      cmp.config.compare.kind,\n      cmp.config.compare.sort_text,\n      cmp.config.compare.length,\n      cmp.config.compare.order,\n    },\n  },\n  ...\n}\n```\n\n#### copilot-cmp:\nNote: It is now **heavily** discouraged to modify the default settings unless an issue gives you good reason to do so.\n\nThe configurable options for this plugin are as follows:\n```lua\n{\n  event = { \"InsertEnter\", \"LspAttach\" },\n  fix_pairs = true,\n}\n```\n##### event\nThe event parameter configures when the source is registered. Unless you have a unique problem for your particular configuration you probably don't want to touch this.\n\n##### fix_pairs\nSuppose you have the following code:\n`print('h')`\nCopilot might try to account for the `'` and `)` and complete it with this:\n`print('hello`\n\nThis is not good behavior for consistency reasons and will just end up deleting the two ending characters. This option fixes that. Don't turn this off unless you are having problems with pairs and believe this might be causing them.\n","funding_links":[],"categories":["Lua","Tab completion"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbirenbaum%2Fcopilot-cmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzbirenbaum%2Fcopilot-cmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbirenbaum%2Fcopilot-cmp/lists"}