• Stars
    star
    6,847
  • Rank 5,478 (Top 0.2 %)
  • Language
    Lua
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A completion plugin for neovim coded in Lua.

nvim-cmp

A completion engine plugin for neovim written in Lua. Completion sources are installed from external repositories and "sourced".

demo.mp4

Readme!

  1. There is a GitHub issue that documents breaking changes for nvim-cmp. Subscribe to the issue to be notified of upcoming breaking changes.
  2. This is my hobby project. You can support me via GitHub sponsors.
  3. Bug reports are welcome, but don't expect a fix unless you provide minimal configuration and steps to reproduce your issue.
  4. The cmp.mapping.preset.* is pre-defined configuration that aims to mimic neovim's native like behavior. It can be changed without announcement. Please manage key-mapping by yourself.

Concept

  • Full support for LSP completion related capabilities
  • Powerful customizability via Lua functions
  • Smart handling of key mappings
  • No flicker

Setup

This example configuration uses vim-plug as the plugin manager and vim-vsnip as a snippet plugin.

call plug#begin(s:plug_dir)
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'

" For vsnip users.
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'

" For luasnip users.
" Plug 'L3MON4D3/LuaSnip'
" Plug 'saadparwaiz1/cmp_luasnip'

" For ultisnips users.
" Plug 'SirVer/ultisnips'
" Plug 'quangnguyen30192/cmp-nvim-ultisnips'

" For snippy users.
" Plug 'dcampos/nvim-snippy'
" Plug 'dcampos/cmp-snippy'

call plug#end()

lua <<EOF
  -- Set up nvim-cmp.
  local cmp = require'cmp'

  cmp.setup({
    snippet = {
      -- REQUIRED - you must specify a snippet engine
      expand = function(args)
        vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
        -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
        -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
        -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
      end,
    },
    window = {
      -- completion = cmp.config.window.bordered(),
      -- documentation = cmp.config.window.bordered(),
    },
    mapping = cmp.mapping.preset.insert({
      ['<C-b>'] = cmp.mapping.scroll_docs(-4),
      ['<C-f>'] = cmp.mapping.scroll_docs(4),
      ['<C-Space>'] = cmp.mapping.complete(),
      ['<C-e>'] = cmp.mapping.abort(),
      ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
    }),
    sources = cmp.config.sources({
      { name = 'nvim_lsp' },
      { name = 'vsnip' }, -- For vsnip users.
      -- { name = 'luasnip' }, -- For luasnip users.
      -- { name = 'ultisnips' }, -- For ultisnips users.
      -- { name = 'snippy' }, -- For snippy users.
    }, {
      { name = 'buffer' },
    })
  })

  -- Set configuration for specific filetype.
  cmp.setup.filetype('gitcommit', {
    sources = cmp.config.sources({
      { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
    }, {
      { name = 'buffer' },
    })
  })

  -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
  cmp.setup.cmdline({ '/', '?' }, {
    mapping = cmp.mapping.preset.cmdline(),
    sources = {
      { name = 'buffer' }
    }
  })

  -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
  cmp.setup.cmdline(':', {
    mapping = cmp.mapping.preset.cmdline(),
    sources = cmp.config.sources({
      { name = 'path' }
    }, {
      { name = 'cmdline' }
    })
  })

  -- Set up lspconfig.
  local capabilities = require('cmp_nvim_lsp').default_capabilities()
  -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
  require('lspconfig')['<YOUR_LSP_SERVER>'].setup {
    capabilities = capabilities
  }
EOF

Where can I find more completion sources?

Have a look at the Wiki and the nvim-cmp GitHub topic.

Where can I find advanced configuration examples?

See the Wiki.

More Repositories

1

nvim-compe

Auto completion Lua plugin for nvim
Lua
1,288
star
2

cmp-nvim-lsp

nvim-cmp source for neovim builtin LSP client
Lua
894
star
3

vim-vsnip

Snippet plugin for vim/nvim that supports LSP/VSCode's snippet format.
Vim Script
831
star
4

cmp-nvim-lsp-signature-help

cmp-nvim-lsp-signature-help
Lua
496
star
5

vscode-langservers-extracted

vscode-langservers bin collection.
Shell
487
star
6

cmp-buffer

nvim-cmp source for buffer words
Lua
475
star
7

cmp-path

nvim-cmp source for path
Lua
462
star
8

cmp-cmdline

nvim-cmp source for vim's cmdline
Lua
395
star
9

cmp-nvim-lua

nvim-cmp source for nvim lua
Lua
279
star
10

cmp-nvim-lsp-document-symbol

nvim-cmp source for textDocument/documentSymbol via nvim-lsp.
Lua
164
star
11

nvim-insx

Flexible key mapping manager.
Lua
153
star
12

cmp-emoji

nvim-cmp source for emoji
Lua
142
star
13

cmp-copilot

copilot.vim source for nvim-cmp
Lua
125
star
14

vim-vsnip-integ

vim-vsnip integrations to other plugins.
Vim Script
119
star
15

cmp-calc

nvim-cmp source for math calculation
Lua
107
star
16

nvim-pasta

The yank/paste enhancement plugin for neovim.
Lua
103
star
17

cmp-vsnip

nvim-cmp source for vim-vsnip
Lua
81
star
18

vim-searchx

The extended search motion.
Vim Script
77
star
19

vim-eft

enhanced f/t
Vim Script
72
star
20

cmp-omni

nvim-cmp source for omnifunc
Lua
39
star
21

vim-seak

search + seek = seak. The plugin that enhances the `/` and `?`.
Vim Script
36
star
22

nvim-gtd

LSP's Go to definition plugin for neovim.
Lua
35
star
23

vim-lamp

💡Language Server Protocol client for Vim.
Vim Script
33
star
24

js-co-on

co based event emitter handling.
JavaScript
33
star
25

nvim-kit

My personal Lua utilities for neovim.
Lua
27
star
26

vim-vital-vs

Vim Script
19
star
27

nvim-dansa

Guess the indent from lines of around.
Lua
18
star
28

denops-popup

https://deno.land/x/denops_popup
Vim Script
18
star
29

vim-gindent

General indentexpr plugin for vim and nvim.
Lua
17
star
30

nvim-lua-rpc-example

Lua
16
star
31

nvim-lua-rpc-example-with-headless

Use nvim --headless for asynchronous processing
Lua
13
star
32

nvim-linkedit

Lua
13
star
33

nvim-matcha

A fuzzy finding plugin for neovim (for my personal use)
12
star
34

vim-candle

Candidates listing engine for vim/nvim built on yaegi on golang.
Vim Script
11
star
35

cmp-core-example

Lua
11
star
36

vim-neco-calc

neocomplcache/neocomplete/deoplete calculates plugin.
Vim Script
10
star
37

vim-versions

useful interface for version control.
Vim Script
9
star
38

vim-compete

Auto completion plugin for vim/nvim that supports fuzzy match.
Vim Script
9
star
39

deno-json-rpc

Strongly typed json-rpc module for deno.
TypeScript
8
star
40

state-use

Simple state manager for React
TypeScript
8
star
41

fern-mapping-collapse-or-leave.vim

Vim Script
7
star
42

vim-denite-gitto

denite with vim-gitto
Python
7
star
43

srimmer

Srimmer provides simple api to use react and immer.
TypeScript
6
star
44

vim-unmatchparen

highlight unmatch parens.
Vim Script
6
star
45

deno-nvim-types

The Nvim API type definition for TypeScript.
TypeScript
6
star
46

nvim-plugin-template

Makefile
6
star
47

msw-snapshot

Transparently create an API cache for testing.
TypeScript
5
star
48

vim-foolish-move

Vim Script
5
star
49

deoplete-vim-lsc

deoplete source for vim-lsc.
Vim Script
4
star
50

hrsh7th

My profile.
4
star
51

fern-mapping-call-function.vim

Vim Script
4
star
52

vim-aim

This plugin provides motion that similar to /. (experimental)
Vim Script
4
star
53

completion-snippet

The vim-vsnip snippet collection for completion.
4
star
54

nvim-tuil

nvim plugin utilities that can be embed your plugin.
Lua
3
star
55

vim-minx

Extended insert-mode mapping manager.
Vim Script
3
star
56

js-gulp-component-build

gulp plugin to build component.
JavaScript
3
star
57

vim-compete-lamp

Vim Script
3
star
58

vsnip-snippet-plugin-demo

Vim Script
2
star
59

compe-lamp

vim-lamp source for compe for my personal use.
Vim Script
2
star
60

js-modelis

Modelis javascript modeling support.
JavaScript
2
star
61

vim-lamp-extensions

Vim Script
2
star
62

nvim-automa-poc

POC of plugin that will be called `nvim-automa`
Lua
2
star
63

node-monores

monorepo scripts.
TypeScript
2
star
64

frontend-testing-demo

https://hrsh7th.github.io/frontend-testing-demo/main/storybook
TypeScript
2
star
65

vim-gitto

vim-gitto
Vim Script
2
star
66

deoplete-lamp

deoplete source for vim-lamp.
Vim Script
1
star
67

vim-neco-snippets

neocomplcache my snippets.
1
star
68

vim-feeling-move

Vim Script
1
star
69

denite-converter-prioritize-basename

Python
1
star
70

denops-sandbox

TypeScript
1
star
71

deoplete-calc

calculates at completion.
Python
1
star
72

nvim-lapi

1
star
73

vim-picka

Vim Script
1
star
74

js-modelis-assurance

assucrance plugin for modelis.
JavaScript
1
star
75

refnew-react

refnew react binding.
TypeScript
1
star
76

deoplete-fname

filename completion for deoplete.nvim.
Python
1
star
77

vim-diffkit

Buffer diff management in VimL. Improve performance for getting buffer's diff.
Vim Script
1
star
78

immer-deps

Auto update dependencies, when immer's produce.
TypeScript
1
star
79

asyncomplete-lamp

asyncomplete source for vim-lamp.
Vim Script
1
star
80

react-inview-hook

react hooks & intersection-observer
TypeScript
1
star
81

vim-locon

local config in vimrc.
Vim Script
1
star
82

vim-compete-omnifunc

Vim Script
1
star
83

vim-vital-deno

vim x deno (experimental)
1
star
84

diagnostics.nvim

Experimental diagnostics service for neovim.
Vim Script
1
star
85

slow-lsp-demo

TypeScript
1
star
86

vim-effort-gf

Vim Script
1
star
87

sandbox

Lua
1
star
88

vim-compete-lsp

vim-lsp source for vim-compete.
Vim Script
1
star
89

xhr-snapshot

TypeScript
1
star
90

refnew

proxy based state management utility.
TypeScript
1
star
91

compe-conjure

compe-nvim source for conjure
Lua
1
star
92

babel-plugin-tree-shakable

good manner cjs files to mjs. this is very very experimental. do not use.
JavaScript
1
star