Skip to content
The Chat Archive
gpt-4-1106-preview· OpenAI Arena Human Preference 55K

Recommend a neovim completion plugin.

  1. User

    Recommend a neovim completion plugin.

  2. Assistant

    One of the most popular completion plugins for Neovim is nvim-cmp. It is a highly configurable autocompletion plugin that integrates with a variety of sources to provide intelligent completion for different programming languages and file types.

    Here's how you can install nvim-cmp with the popular plugin manager packer.nvim:

    1. First, ensure you have Neovim (0.5.0 or later) and packer.nvim installed.
    2. Include nvim-cmp and its dependencies in your packer.nvim configuration:
    use {
      'hrsh7th/nvim-cmp',
      requires = {
        'hrsh7th/cmp-buffer', -- buffer completions
        'hrsh7th/cmp-path', -- path completions
        'hrsh7th/cmp-cmdline', -- cmdline completions
        'hrsh7th/cmp-nvim-lsp', -- LSP completions
        'hrsh7th/cmp-nvim-lua', -- Neovim Lua API completions
      },
      config = function()
        -- Setup nvim-cmp here or in a separate file
      end
    }
    
    1. Configure nvim-cmp according to your preferences:
    -- Get the `cmp` setup function
    local cmp = require'cmp'
    
    cmp.setup({
      -- You can set up completion for multiple features (buffer, path, etc.)
      sources = cmp.config.sources({
        { name = 'nvim_lsp' },
        { name = 'nvim_lua' },
        -- more sources can be added here
      }),
    
      -- Define how the completion menu looks and behaves
      window = {
        -- Customize the completion menu window
        completion = cmp.config.window.bordered(),
        documentation = cmp.config.window.bordered(),
      },
    
      -- Set up key mappings (this is an example, customize as needed)
      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.
      }),
    })
    
    -- You can
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.