{"id":13484411,"url":"https://github.com/hrsh7th/nvim-compe","last_synced_at":"2025-10-02T23:35:22.400Z","repository":{"id":45517026,"uuid":"271179578","full_name":"hrsh7th/nvim-compe","owner":"hrsh7th","description":"Auto completion Lua plugin for nvim","archived":true,"fork":false,"pushed_at":"2021-10-02T15:28:26.000Z","size":784,"stargazers_count":1280,"open_issues_count":5,"forks_count":54,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-15T10:57:08.659Z","etag":null,"topics":["neovim","neovim-plugin","nvim","nvim-plugin"],"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/hrsh7th.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["hrsh7th"]}},"created_at":"2020-06-10T04:35:44.000Z","updated_at":"2024-11-02T18:04:07.000Z","dependencies_parsed_at":"2022-07-18T08:30:51.840Z","dependency_job_id":null,"html_url":"https://github.com/hrsh7th/nvim-compe","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrsh7th%2Fnvim-compe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrsh7th%2Fnvim-compe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrsh7th%2Fnvim-compe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrsh7th%2Fnvim-compe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hrsh7th","download_url":"https://codeload.github.com/hrsh7th/nvim-compe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235051515,"owners_count":18928177,"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":["neovim","neovim-plugin","nvim","nvim-plugin"],"created_at":"2024-07-31T17:01:23.943Z","updated_at":"2025-10-02T23:35:21.971Z","avatar_url":"https://github.com/hrsh7th.png","language":"Lua","funding_links":["https://github.com/sponsors/hrsh7th"],"categories":["Lua"],"sub_categories":[],"readme":"# Warning\n\nnvim-compe is now deprecated. Please use [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) the successor of nvim-compe.\n\nnvim-compe still works but new feature and bugfixes will be stopped.\n\n# nvim-compe\n\nAuto completion plugin for nvim.\n\n## Table Of Contents\n\n- [Concept](#concept)\n- [Features](#features)\n- [Usage](#usage)\n  - [Prerequisite](#prerequisite)\n    - [Vim script Config](#vim-script-config)\n    - [Lua Config](#lua-config)\n  - [Mappings](#mappings)\n  - [Highlight](#highlight)\n- [Built-in sources](#built-in-sources)\n  - [Common](#common)\n  - [Neovim-specific](#neovim-specific)\n  - [External-plugin](#external-plugin)\n- [External sources](#external-sources)\n- [Known issues](#known-issues)\n- [FAQ](#faq)\n  - [Can't get sorting to work correctly](#cant-get-sorting-to-work-correctly)\n  - [How to use LSP snippet?](#how-to-use-lsp-snippet)\n  - [How to use tab to navigate completion menu?](#how-to-use-tab-to-navigate-completion-menu)\n  - [How to expand snippets from completion menu?](#how-to-expand-snippets-from-completion-menu)\n  - [How to automatically select the first match?](#how-to-automatically-select-the-first-match)\n- [Demo](#demo)\n  - [Auto Import](#auto-import)\n  - [LSP + Magic Completion](#lsp--rust_analyzers-magic-completion)\n  - [Buffer Source Completion](#buffer-source-completion)\n  - [Calc Completion](#calc-completion)\n  - [Nvim Lua Completion](#nvim-lua-completion)\n  - [Vsnip Completion](#vsnip-completion)\n  - [Snippets.nvim Completion](#snippetsnvim-completion)\n  - [Treesitter Completion](#treesitter-completion)\n  - [Tag Completion](#tag-completion)\n  - [Spell Completion](#spell-completion)\n\n## Concept\n\n- Simple core\n- No flicker\n- Lua source \u0026 Vim source\n- Better matching algorithm\n- Support LSP completion features (trigger character, isIncomplete, expansion)\n- Respect VSCode/LSP API design\n\n## Features\n\n- VSCode compatible expansion handling\n  - rust-analyzer's\n    [Magic completion](https://rust-analyzer.github.io/manual.html#magic-completions)\n  - vscode-html-languageserver-bin's closing tag completion\n  - Other complex expansion are supported\n- Flexible Custom Source API\n  - The source can support `documentation` / `resolve` / `confirm`\n- Better fuzzy matching algorithm\n  - `gu` can be matched `get_user`\n  - `fmodify` can be matched `fnamemodify`\n  - See [matcher.lua](./lua/compe/matcher.lua#L57) for implementation details\n- Buffer source carefully crafted\n  - The buffer source will index buffer words by filetype specific regular\n    expression if needed\n\n## Usage\n\nDetailed docs in [here](./doc/compe.txt) or `:help compe`.\n\n### Prerequisite\n\nNeovim version 0.5.0 or above.\n\nYou must set `completeopt` to `menuone,noselect` which can be easily done\nas follows.\n\nUsing Vim script\n\n```viml\nset completeopt=menuone,noselect\n```\n\nUsing Lua\n\n```lua\nvim.o.completeopt = \"menuone,noselect\"\n```\n\nThe `source` option is required if you want to enable but others can be omitted.\n\n#### Vim script Config\n\n```viml\nlet g:compe = {}\nlet g:compe.enabled = v:true\nlet g:compe.autocomplete = v:true\nlet g:compe.debug = v:false\nlet g:compe.min_length = 1\nlet g:compe.preselect = 'enable'\nlet g:compe.throttle_time = 80\nlet g:compe.source_timeout = 200\nlet g:compe.resolve_timeout = 800\nlet g:compe.incomplete_delay = 400\nlet g:compe.max_abbr_width = 100\nlet g:compe.max_kind_width = 100\nlet g:compe.max_menu_width = 100\nlet g:compe.documentation = v:true\n\nlet g:compe.source = {}\nlet g:compe.source.path = v:true\nlet g:compe.source.buffer = v:true\nlet g:compe.source.calc = v:true\nlet g:compe.source.nvim_lsp = v:true\nlet g:compe.source.nvim_lua = v:true\nlet g:compe.source.vsnip = v:true\nlet g:compe.source.ultisnips = v:true\nlet g:compe.source.luasnip = v:true\nlet g:compe.source.emoji = v:true\n```\n\n#### Lua Config\n\n```lua\nrequire'compe'.setup {\n  enabled = true;\n  autocomplete = true;\n  debug = false;\n  min_length = 1;\n  preselect = 'enable';\n  throttle_time = 80;\n  source_timeout = 200;\n  resolve_timeout = 800;\n  incomplete_delay = 400;\n  max_abbr_width = 100;\n  max_kind_width = 100;\n  max_menu_width = 100;\n  documentation = {\n    border = { '', '' ,'', ' ', '', '', '', ' ' }, -- the border option is the same as `|help nvim_open_win|`\n    winhighlight = \"NormalFloat:CompeDocumentation,FloatBorder:CompeDocumentationBorder\",\n    max_width = 120,\n    min_width = 60,\n    max_height = math.floor(vim.o.lines * 0.3),\n    min_height = 1,\n  };\n\n  source = {\n    path = true;\n    buffer = true;\n    calc = true;\n    nvim_lsp = true;\n    nvim_lua = true;\n    vsnip = true;\n    ultisnips = true;\n    luasnip = true;\n  };\n}\n```\n\n### Mappings\n\n```viml\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-Space\u003e compe#complete()\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cCR\u003e      compe#confirm('\u003cCR\u003e')\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-e\u003e     compe#close('\u003cC-e\u003e')\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-f\u003e     compe#scroll({ 'delta': +4 })\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-d\u003e     compe#scroll({ 'delta': -4 })\n```\n\nIf you use [cohama/lexima.vim](https://github.com/cohama/lexima.vim)\n\n```viml\n\" NOTE: Order is important. You can't lazy loading lexima.vim.\nlet g:lexima_no_default_rules = v:true\ncall lexima#set_default_rules()\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-Space\u003e compe#complete()\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cCR\u003e      compe#confirm(lexima#expand('\u003cLT\u003eCR\u003e', 'i'))\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-e\u003e     compe#close('\u003cC-e\u003e')\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-f\u003e     compe#scroll({ 'delta': +4 })\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-d\u003e     compe#scroll({ 'delta': -4 })\n```\n\nIf you use [Raimondi/delimitMate](https://github.com/Raimondi/delimitMate)\n\n```viml\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-Space\u003e compe#complete()\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cCR\u003e      compe#confirm({ 'keys': \"\\\u003cPlug\u003edelimitMateCR\", 'mode': '' })\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-e\u003e     compe#close('\u003cC-e\u003e')\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-f\u003e     compe#scroll({ 'delta': +4 })\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-d\u003e     compe#scroll({ 'delta': -4 })\n```\n\nIf you use [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs)\n\n```viml\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-Space\u003e compe#complete()\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cCR\u003e      compe#confirm(luaeval(\"require 'nvim-autopairs'.autopairs_cr()\"))\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-e\u003e     compe#close('\u003cC-e\u003e')\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-f\u003e     compe#scroll({ 'delta': +4 })\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cC-d\u003e     compe#scroll({ 'delta': -4 })\n```\n\n### Highlight\n\nYou can change documentation window's highlight group via following.\n\n```viml\nhighlight link CompeDocumentation NormalFloat\n```\n\n\n## Built-in sources\n\n### Common\n\n- buffer\n- path\n- tags\n- spell\n- calc\n- omni (Warning: It has a lot of side-effect.)\n\n### Neovim-specific\n\n- nvim_lsp\n- nvim_lua\n\n### External-plugin\n\n- [vim_lsp](https://github.com/prabirshrestha/vim-lsp)\n- [vim_lsc](https://github.com/natebosch/vim-lsc)\n- [vim-vsnip](https://github.com/hrsh7th/vim-vsnip)\n- [ultisnips](https://github.com/SirVer/ultisnips)\n- [snippets.nvim](https://github.com/norcalli/snippets.nvim)\n- [luasnip](https://github.com/L3MON4D3/LuaSnip)\n- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) (Warning: it sometimes really slow.)\n\n## External sources\n\n- [tabnine](https://github.com/tzachar/compe-tabnine)\n- [zsh](https://github.com/tamago324/compe-zsh)\n- [conjure](https://github.com/tami5/compe-conjure)\n- [dadbod](https://github.com/kristijanhusak/vim-dadbod-completion)\n- [latex-symbols](https://github.com/GoldsteinE/compe-latex-symbols)\n- [tmux](https://github.com/andersevenrud/compe-tmux)\n- [vCard](https://github.com/cbarrete/completion-vcard)\n- [lbdb](https://github.com/codybuell/compe-lbdb)\n\n## Known issues\n\nYou can see the known issues in here.\n\n- [OS related](https://github.com/hrsh7th/nvim-compe/issues?q=+label%3Aos-related+)\n- [Server related](https://github.com/hrsh7th/nvim-compe/issues?q=+label%3Aserver-related+)\n- [Upstream issue](https://github.com/hrsh7th/nvim-compe/issues?q=+label%3Aupstream-issue+)\n- [Next version](https://github.com/hrsh7th/nvim-compe/issues?q=+label%3Anext-version+)\n\nNote: The next-version means [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) now.\n\n## FAQ\n\n### Can't get it work.\n\nIf you are enabling the `omni` source, please try to disable it.\n\n### Incredibly lagging.\n\nIf you are enabling the `treesitter` source, please try to disable it.\n\n### Does not work function signature window.\n\nThe signature help is out of scope of compe.\nIt should be another plugin e.g. [lsp_signature.nvim](https://github.com/ray-x/lsp_signature.nvim)\n\nIf you are enabling the `treesitter` source, please try to disable it.\n\n### How to remove `Pattern not found`?\n\nYou can set `set shortmess+=c` in your vimrc.\n\n\n### How to use LSP snippet?\n\n1. Set `snippetSupport=true` for LSP capabilities.\n\n   ```lua\n   local capabilities = vim.lsp.protocol.make_client_capabilities()\n   capabilities.textDocument.completion.completionItem.snippetSupport = true\n   capabilities.textDocument.completion.completionItem.resolveSupport = {\n     properties = {\n       'documentation',\n       'detail',\n       'additionalTextEdits',\n     }\n   }\n\n   require'lspconfig'.rust_analyzer.setup {\n     capabilities = capabilities,\n   }\n   ```\n\n2. Install `vim-vsnip`\n\n   ```viml\n   Plug 'hrsh7th/vim-vsnip'\n   ```\n\n   or `snippets.nvim`\n\n   ```viml\n   Plug 'norcalli/snippets.nvim'\n   ```\n\n   or `UltiSnips`\n\n   ```viml\n   Plug 'SirVer/ultisnips'\n   ```\n\n   or `LuaSnip`\n\n   ```viml\n   Plug 'L3MON4D3/LuaSnip'\n   ```\n\n### How to use tab to navigate completion menu?\n\n`Tab` and `S-Tab` keys need to be mapped to `\u003cC-n\u003e` and `\u003cC-p\u003e` when completion\nmenu is visible. Following example will use `Tab` and `S-Tab` (shift+tab) to\nnavigate completion menu and jump between\n[vim-vsnip](https://github.com/hrsh7th/vim-vsnip) placeholders when possible:\n\n```lua\nlocal t = function(str)\n  return vim.api.nvim_replace_termcodes(str, true, true, true)\nend\n\nlocal check_back_space = function()\n    local col = vim.fn.col('.') - 1\n    return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil\nend\n\n-- Use (s-)tab to:\n--- move to prev/next item in completion menuone\n--- jump to prev/next snippet's placeholder\n_G.tab_complete = function()\n  if vim.fn.pumvisible() == 1 then\n    return t \"\u003cC-n\u003e\"\n  elseif vim.fn['vsnip#available'](1) == 1 then\n    return t \"\u003cPlug\u003e(vsnip-expand-or-jump)\"\n  elseif check_back_space() then\n    return t \"\u003cTab\u003e\"\n  else\n    return vim.fn['compe#complete']()\n  end\nend\n_G.s_tab_complete = function()\n  if vim.fn.pumvisible() == 1 then\n    return t \"\u003cC-p\u003e\"\n  elseif vim.fn['vsnip#jumpable'](-1) == 1 then\n    return t \"\u003cPlug\u003e(vsnip-jump-prev)\"\n  else\n    -- If \u003cS-Tab\u003e is not working in your terminal, change it to \u003cC-h\u003e\n    return t \"\u003cS-Tab\u003e\"\n  end\nend\n\nvim.api.nvim_set_keymap(\"i\", \"\u003cTab\u003e\", \"v:lua.tab_complete()\", {expr = true})\nvim.api.nvim_set_keymap(\"s\", \"\u003cTab\u003e\", \"v:lua.tab_complete()\", {expr = true})\nvim.api.nvim_set_keymap(\"i\", \"\u003cS-Tab\u003e\", \"v:lua.s_tab_complete()\", {expr = true})\nvim.api.nvim_set_keymap(\"s\", \"\u003cS-Tab\u003e\", \"v:lua.s_tab_complete()\", {expr = true})\n```\n\n### How to expand snippets from completion menu?\n\nUse `compe#confirm()` mapping, as described in section [Mappings](#mappings).\n\n### How to automatically select the first match?\n\n`compe#confirm()` with the select option set to true will select the first item when none has been manually selected. For example:\n\n```lua\nvim.api.nvim_set_keymap(\"i\", \"\u003cCR\u003e\", \"compe#confirm({ 'keys': '\u003cCR\u003e', 'select': v:true })\", { expr = true })\n```\n\n\n### ESC does not close the completion menu\n\nAnother plugin might be interfering with it. [`vim-autoclose`](https://github.com/Townk/vim-autoclose)\ndoes this. You can check the mapping of `\u003cESC\u003e` by running\n\n```\nimap \u003cESC\u003e\n```\n\n`vim-autoclose`'s function looks similar to this:\n\n```\n\u003cEsc\u003e *@pumvisible() ? '\u003cC-E\u003e' : '\u003cC-R\u003e=\u003cSNR\u003e110_FlushBuffer()\u003cCR\u003e\u003cEsc\u003e'\n```\n\nIn the particular case of `vim-autoclose`, the problem can be fixed by adding this setting:\n\n```\nlet g:AutoClosePumvisible = {\"ENTER\": \"\u003cC-Y\u003e\", \"ESC\": \"\u003cESC\u003e\"}\n```\n\nOther plugins might need other custom settings.\n\n## Demo\n\n### Auto Import\n\n![auto import](https://i.imgur.com/GJSKxWK.gif)\n\n### LSP + [rust_analyzer's Magic Completion](https://rust-analyzer.github.io/manual.html#magic-completions)\n\n![lsp](https://i.imgur.com/pMxHkYG.gif)\n\n### Buffer Source Completion\n\n![buffer](https://i.imgur.com/qCfeb5d.gif)\n\n### Calc Completion\n\n![calc](https://i.imgur.com/gfoP9ff.gif)\n\n### Nvim Lua Completion\n\n![nvim lua](https://i.imgur.com/zGfVz2M.gif)\n\n### Vsnip Completion\n\n![vsnip](https://i.imgur.com/y2wNDtC.gif)\n\n### Snippets.nvim Completion\n\n![snippets.nvim](https://i.imgur.com/404KJ7C.gif)\n\n### Treesitter Completion\n\n![treesitter.nvim](https://i.imgur.com/In7Kswu.gif)\n\n### Tag Completion\n\n![tag](https://i.imgur.com/KOAHcM2.gif)\n\n### Spell Completion\n\n![spell](https://i.imgur.com/r12rLBS.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrsh7th%2Fnvim-compe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhrsh7th%2Fnvim-compe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrsh7th%2Fnvim-compe/lists"}