Home

Awesome

WARNING: completion.nvim is no longer maintained

If you are looking for an autocompletion plugin, the neovim LSP team recommends either nvim-cmp or coq_nvim.

Build Status Gitter

completion-nvim

completion-nvim is an auto completion framework that aims to provide a better completion experience with neovim's built-in LSP. Other LSP functionality is not supported.

Features

Demo

Demo using sumneko_lua

Prerequisites

Install

Plug 'nvim-lua/completion-nvim'

Setup

lua require'lspconfig'.pyls.setup{on_attach=require'completion'.on_attach}
" Use completion-nvim in every buffer
autocmd BufEnter * lua require'completion'.on_attach()

NOTE It's okay to set up completion-nvim without lsp. It will simply use another completion source instead(Ex: snippets).

Supported Completion Source

Configuration

Recommended Setting

" Use <Tab> and <S-Tab> to navigate through popup menu
inoremap <expr> <Tab>   pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

" Set completeopt to have a better completion experience
set completeopt=menuone,noinsert,noselect

" Avoid showing message extra message when using completion
set shortmess+=c

Enable/Disable auto popup

let g:completion_enable_auto_popup = 0
"map <c-p> to manually trigger completion
imap <silent> <c-p> <Plug>(completion_trigger)
imap <tab> <Plug>(completion_smart_tab)
imap <s-tab> <Plug>(completion_smart_s_tab)

Enable Snippets Support

" possible value: 'UltiSnips', 'Neosnippet', 'vim-vsnip', 'snippets.nvim'
let g:completion_enable_snippet = 'UltiSnips'

LSP Based Snippet parsing

Right now, vim-vsnip (requiring vim-vsnip-integ) and snippets.nvim are supported.

Chain Completion Support

Changing Completion Confirm key

let g:completion_confirm_key = "\<C-y>"
let g:completion_confirm_key = ""
imap <expr> <cr>  pumvisible() ? complete_info()["selected"] != "-1" ?
                 \ "\<Plug>(completion_confirm_completion)"  : "\<c-e>\<CR>" :  "\<CR>"

Enable/Disable auto hover

let g:completion_enable_auto_hover = 0

Enable/Disable auto signature

let g:completion_enable_auto_signature = 0

Sorting completion items

" possible value: "length", "alphabet", "none"
let g:completion_sorting = "length"

Matching Strategy

let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy', 'all']

NOTE Fuzzy match highly dependent on what language server you're using. It might not work as you expect on some language server.

g:completion_matching_ignore_case = 1
g:completion_matching_smart_case = 1

Trigger Characters

let g:completion_trigger_character = ['.', '::']

NOTE use :lua print(vim.inspect(vim.lsp.buf_get_clients()[1].server_capabilities.completionProvider.triggerCharacters)) to see the trigger character of your language server.

augroup CompletionTriggerCharacter
    autocmd!
    autocmd BufEnter * let g:completion_trigger_character = ['.']
    autocmd BufEnter *.c,*.cpp let g:completion_trigger_character = ['.', '::']
augroup end

Trigger keyword length

let g:completion_trigger_keyword_length = 3 " default = 1

NOTE completion-nvim will ignore keyword length if you're on trigger character.

Trigger on delete

let g:completion_trigger_on_delete = 1

Timer Adjustment

let g:completion_timer_cycle = 200 "default value is 80

Per Server Setup

Trouble Shooting