vimtricks.wiki Concise Vim tricks, one at a time.

How do I enable native LSP-powered completion in Neovim without installing nvim-cmp or other plugins?

Answer

vim.lsp.completion.enable()

Explanation

Neovim 0.11 introduced vim.lsp.completion.enable(), which wires LSP completion results directly into Neovim's built-in completion system — no nvim-cmp or third-party plugin required. Enable it in an LspAttach autocmd to get language server completions using native <C-n>/<C-p> mechanics.

How it works

Call vim.lsp.completion.enable() in your LspAttach handler, passing the client ID, buffer, and options:

vim.api.nvim_create_autocmd('LspAttach', {
  callback = function(args)
    local client = vim.lsp.get_client_by_id(args.data.client_id)
    if client and client.supports_method('textDocument/completion') then
      vim.lsp.completion.enable(true, args.data.client_id, args.buf, {
        autotrigger = true,
      })
    end
  end,
})
  • autotrigger = true — automatically show completions as you type (like nvim-cmp)
  • autotrigger = false — only trigger on <C-x><C-o> or your own mapping
  • Snippets from LSP completion items are expanded automatically via vim.snippet
  • Navigate completions with <C-n> / <C-p>, confirm with <CR> or <C-y>

Tips

  • This is only available in Neovim 0.11+; check with :lua print(vim.version().minor)
  • Works alongside vim.snippet for tabstop/placeholder navigation after accepting snippet completions
  • Add a <Tab> mapping that checks vim.snippet.jumpable(1) to jump snippet fields after acceptance
  • For simple setups, this eliminates the need for nvim-cmp while still getting LSP completions, signature help, and snippet expansion

Next

What is the difference between the inner word (iw) and inner WORD (iW) text objects in Vim?