All Projects → mfussenegger → nvim-lsp-compl

mfussenegger / nvim-lsp-compl

Licence: GPL-3.0 License
A fast and asynchronous auto-completion plugin for Neovim >= 0.5, focused on LSP.

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to nvim-lsp-compl

spellsitter.nvim
Treesitter powered spellchecker
Stars: ✭ 251 (+445.65%)
Mutual labels:  neovim, neovim-plugin
nvim-config
My neovim config
Stars: ✭ 63 (+36.96%)
Mutual labels:  autocompletion, neovim-plugin
Intero.nvim
Haskell+Neovim lightning fast autocompletion and other IDE functionality
Stars: ✭ 76 (+65.22%)
Mutual labels:  autocompletion, neovim
Vim Vsnip
Snippet plugin for vim/nvim that supports LSP/VSCode's snippet format.
Stars: ✭ 224 (+386.96%)
Mutual labels:  neovim, neovim-plugin
lir.nvim
Neovim file explorer
Stars: ✭ 194 (+321.74%)
Mutual labels:  neovim, neovim-plugin
Vim Ghost
Vim/Nvim client for GhostText - Edit browser text areas in Vim/Neovim
Stars: ✭ 245 (+432.61%)
Mutual labels:  neovim, neovim-plugin
sphinx.nvim
Sphinx integrations for Neovim
Stars: ✭ 64 (+39.13%)
Mutual labels:  autocompletion, neovim-plugin
Lsp Status.nvim
Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
Stars: ✭ 201 (+336.96%)
Mutual labels:  neovim, neovim-plugin
Comment.nvim
🧠 💪 // Smart and powerful comment plugin for neovim. Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more
Stars: ✭ 796 (+1630.43%)
Mutual labels:  neovim, neovim-plugin
nvim-jdtls
Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
Stars: ✭ 282 (+513.04%)
Mutual labels:  neovim, neovim-plugin
Indent Blankline.nvim
Indent guides for Neovim
Stars: ✭ 203 (+341.3%)
Mutual labels:  neovim, neovim-plugin
virt-column.nvim
Display a character as the colorcolumn
Stars: ✭ 64 (+39.13%)
Mutual labels:  neovim, neovim-plugin
Lush.nvim
Define Neovim themes as a DSL in lua, with real-time feedback.
Stars: ✭ 204 (+343.48%)
Mutual labels:  neovim, neovim-plugin
Vim Terraform Completion
A (Neo)Vim Autocompletion and linter for Terraform, a HashiCorp tool
Stars: ✭ 280 (+508.7%)
Mutual labels:  autocompletion, neovim
Nvim Go
Go development plugin for Neovim written in pure Go
Stars: ✭ 207 (+350%)
Mutual labels:  neovim, neovim-plugin
Coc.nvim
Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Stars: ✭ 18,268 (+39613.04%)
Mutual labels:  autocompletion, neovim-plugin
Neovim Ruby
Ruby support for Neovim
Stars: ✭ 202 (+339.13%)
Mutual labels:  neovim, neovim-plugin
Lualine.nvim
A blazing fast and easy to configure neovim statusline written in pure lua.
Stars: ✭ 198 (+330.43%)
Mutual labels:  neovim, neovim-plugin
nvim context vt
Virtual text context for neovim treesitter
Stars: ✭ 193 (+319.57%)
Mutual labels:  neovim, neovim-plugin
close-buffers.nvim
📑 Delete multiple vim buffers based on different conditions
Stars: ✭ 54 (+17.39%)
Mutual labels:  neovim, neovim-plugin

nvim-lsp-compl

A fast and asynchronous auto-completion plugin for Neovim >= 0.5.1, focused on LSP.

Motivation

Why another one?

I wrote the initial code for this within my dotfiles long before plugins like nvim-compe popped up and tuned it over time to accommodate my workflow.

There have been some voices looking for something smaller than nvim-compe, so I decided to extract the code from my dotfiles and make it re-usable for others.

Features

  • Automatically triggers completion on trigger characters advocated by the language server
  • Automatically triggers signature help on characters advocated by the language server
  • Apply additional text edits (Used to resolve imports and so on)
  • Supports lazy resolving of additional text edits if the language server has the capability
  • Optionally supports server side fuzzy matching
  • Optionally supports LSP snippet expansion if LuaSnip or vsnip is installed or a custom snippet-applier is registered

If you need anything else, you better use nvim-compe.

Opinionated behaviors:

  • Snippets are only expanded via explicit opt-in
  • The word in the completion candidates is tuned to exclude parenthesis and arguments, unless you use the snippet expansion.

Non-Goals

Installation

  • Install Neovim >= 0.5.1
  • Install nvim-lsp-compl like any other plugin
    • If using vim-plug: Plug 'mfussenegger/nvim-lsp-compl'
    • If using packer.nvim: use 'mfussenegger/nvim-lsp-compl'

Configuration

You need to call the attach method when the language server clients attaches to a buffer.

If you're using lspconfig you could do this like this:

lua require'lspconfig'.pyls.setup{on_attach=require'lsp_compl'.attach}

If you want to utilize server side fuzzy completion, you would call it like this:

lua require'lspconfig'.pyls.setup{
  on_attach = function(client, bufnr)
    require'lsp_compl'.attach(client, bufnr, { server_side_fuzzy_completion = true })
  end,
}

To expand snippets you need to explicitly accept a completion candidate:

inoremap <expr> <CR> (luaeval("require'lsp_compl'.accept_pum()") ? "\<c-y>" : "\<CR>")

Currently snippet expansion tries LuaSnip if available and otherwise falls back to use vim-vsnip, but you can override the expand_snippet function to use a different snippet engine:

require('lsp_compl').expand_snippet = vim.fn['vsnip#anonymous']

Or

require('lsp_compl').expand_snippet = require('luasnip').lsp_expand

The function takes a single argument - the snippet - and is supposed to expand it.

FAQ

Can I disable the automatic signature popup?

Yes, if you set the signature_help_trigger_characters to an empty table:

on_attach = function(client, bufnr)
  client.resolved_capabilities.signature_help_trigger_characters = {}
  require'lsp_compl'.attach(client, bufnr)
end

Can I customize the trigger characters for completion?

Yes, if you override the triggerCharacters:

on_attach = function(client, bufnr)
  client.server_capabilities.completionProvider.triggerCharacters = {'a', 'e', 'i', 'o', 'u'}
  require'lsp_compl'.attach(client, bufnr)
end

Can I trigger the completion manually?

Yes, call require'lsp_compl'.trigger_completion() while in insert mode. But this won't be much different from using the vim.lsp.omnifunc via i_CTRL-X_CTRL-O.

Can I re-trigger completion when I hit backspace or <C-w> while completion is active?

Yes, you have three options:

  1. Manually trigger the completion (see previous question)
  2. Enable trigger_on_delete:
  -- ...
  on_attach = function(client, bufnr)
    require'lsp_compl'.attach(client, bufnr, { trigger_on_delete = true })
  end
  -- ...
  1. Define a key mapping that always re-triggers it:
inoremap <expr> <BS> (pumvisible() ? "\<BS><cmd> :lua require'lsp_compl'.trigger_completion()<CR>" : "\<BS>")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].