Giter Club home page Giter Club logo

completion-nvim's Introduction

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

  • Asynchronous completion using the libuv api.
  • Automatically open hover windows when popupmenu is available.
  • Automatically open signature help if it's available.
  • Snippets integration with UltiSnips, Neosnippet, vim-vsnip, and snippets.nvim.
  • Apply additionalTextEdits in LSP spec if it's available.
  • Chain completion support inspired by vim-mucomplete

Demo

Demo using sumneko_lua

Prerequisites

  • Neovim nightly
  • You should set up your language server of choice with the help of nvim-lspconfig

Install

  • Install with any plugin manager by using the path on GitHub.
Plug 'nvim-lua/completion-nvim'

Setup

  • completion-nvim requires several autocommands set up to work properly. You should set it up using the on_attach function like this.
lua require'lspconfig'.pyls.setup{on_attach=require'completion'.on_attach}
  • Change pyls to whichever language server you're using.
  • If you want completion-nvim to be set up for all buffers instead of only being used when lsp is enabled, call the on_attach function directly:
" 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

  • By default auto popup is enabled, turn it off by
let g:completion_enable_auto_popup = 0
  • Or you can toggle auto popup on the fly by using command CompletionToggle
  • You can manually trigger completion with mapping key by
"map <c-p> to manually trigger completion
imap <silent> <c-p> <Plug>(completion_trigger)
  • Or you want to use <Tab> as trigger keys
imap <tab> <Plug>(completion_smart_tab)
imap <s-tab> <Plug>(completion_smart_s_tab)

Enable Snippets Support

  • By default other snippets source support are disabled, turn them on by
" possible value: 'UltiSnips', 'Neosnippet', 'vim-vsnip', 'snippets.nvim'
let g:completion_enable_snippet = 'UltiSnips'
  • Supports UltiSnips, Neosnippet, vim-vsnip and snippets.nvim

LSP Based Snippet parsing

  • Some language server have snippet support but neovim couldn't handle that for now, completion-nvim can integrate with other LSP snippet parsing plugin for this support.

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

Chain Completion Support

  • completion-nvim supports chain completion, which use other completion sources and ins-completion as a fallback for lsp completion.

  • See wiki for details on how to set this up.

Changing Completion Confirm key

  • By default <CR> is used to confirm completion and expand snippets, change it by
let g:completion_confirm_key = "\<C-y>"
  • Make sure to use " " and add escape key \ to avoid parsing issues.
  • If the confirm key has a fallback mapping, for example when using the auto pairs plugin, it maps to <CR>. You can avoid using the default confirm key option and use a mapping like this instead.
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

  • By default when navigating through completion items, LSP's hover is automatically called and displays in a floating window. Disable it by
let g:completion_enable_auto_hover = 0

Enable/Disable auto signature

  • By default signature help opens automatically whenever it's available. Disable it by
let g:completion_enable_auto_signature = 0

Sorting completion items

  • You can decide how your items being sorted in the popup menu. The default value is "alphabet", change it by
" possible value: "length", "alphabet", "none"
let g:completion_sorting = "length"
  • If you don't want any sorting, you can set this value to "none".

Matching Strategy

  • There are three different kind of matching technique implement in completion-nvim: substring, fuzzy, exact or all.

  • You can specify a list of matching strategy, completion-nvim will loop through the list and assign priority from high to low. For example

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.

  • You can also enable ignore case matching by
g:completion_matching_ignore_case = 1
  • Or smart case matching by
g:completion_matching_smart_case = 1

Trigger Characters

  • By default, completion-nvim respect the trigger character of your language server, if you want more trigger characters, add it by
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.

  • If you want different trigger character for different languages, wrap it in an autocommand like
augroup CompletionTriggerCharacter
    autocmd!
    autocmd BufEnter * let g:completion_trigger_character = ['.']
    autocmd BufEnter *.c,*.cpp let g:completion_trigger_character = ['.', '::']
augroup end

Trigger keyword length

  • You can specify keyword length for triggering completion, if the current word is less then keyword length, completion won't be triggered.
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

  • completion-nvim doesn't trigger completion on delete by default because sometimes I've found it annoying. However, you can enable it by
let g:completion_trigger_on_delete = 1

Timer Adjustment

  • completion-nvim uses a timer to control the rate of completion. You can adjust the timer rate by
let g:completion_timer_cycle = 200 "default value is 80

Per Server Setup

Trouble Shooting

  • This plugin is in the early stages and might have unexpected issues. Please follow wiki for trouble shooting.
  • Feel free to post issues on any unexpected behavior or open a feature request!

completion-nvim's People

Contributors

7415963987456321 avatar aca avatar acaroirisbond avatar adrian5 avatar brenopacheco avatar cbarrete avatar ckipp01 avatar fsouza avatar glepnir avatar halkn avatar hampustagerud avatar haorenw1025 avatar hrsh7th avatar humancalico avatar janvaliska avatar jaywonchung avatar joaofukuda avatar kdheepak avatar klauer avatar kristijanhusak avatar lukas-reineke avatar nhooyr avatar ranjithshegde avatar rockerboo avatar runiq avatar tjdevries avatar tomcur avatar vigoux avatar xuyuanp avatar ybc37 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

completion-nvim's Issues

Arguments navigation

Is there a way to navigate the arguments of a function that are completed?

For example for python itertools.chain completes to:

itertools.chain(${1:*iterables})${0}

Is there a way to, after triggering completion, to move the cursor to each of the arguments? Similar to how it works for UltiSnips?

If not, can the arguments be disabled.
As it is now it takes more time to clean up than having no completion. :)

Thanks for the nice plugin!

Enable/Disable completion in strings

Similar to the option to enable/disable completion in comments, it would be nice with an option to also enable/disable them in strings. Mostly for the same reasons they're annoying in comments.

Hover window goes off screen at times causing an error

I noticed today when I had my terminal split that the hover window was going off too far to the right. I'm not 100% sure what is actually causing this, but it also caused an Error to appear as well. Here is a screen shot of what I mean for the window going too far:

Screenshot 2020-05-02 at 10 11 20

The arrow is pointing towards the edge of my terminal, and see how it's cutting the floating window. Then the following Error is appearing:

Error executing vim.schedule lua callback: ...pp/.vim/plugged/completion-nvim/lua/completion/hover.lua:220: 'width' key must be a positive Integer

If you need any help with reproduction or any more details, please let me know. I'm using this with Metals installed via LspInstall from neovim/nvim-lsp.

Thanks for you great work!

Add delay between keypress and autocomplete pop-up

Hi,

First of all, thanks for creating this plugin, I've been looking for a good, fast, and minimal autocomplete plugin for Neovim's native LSP implementation for a while, this one fits the bill nicely! :)

Just one small feature request: would it be possible add a configurable amount of delay between pressing a key and having the completion pop-up window open?

It's a little distracting to be typing away and having the box constantly flickering away below the cursor. Adding maybe 150-200ms delay would help a great deal with my focus.

Thanks.

Conflict with auto-pairs plugin

I don't know why, but this plugin breaks the jiangmiao/auto-pairs feature of breaking a new statement in a new line when the user presses ENTER:

Before install this plugin:

// from
it('test', () => {<cursor><CR>})
//to
it('test', () => {
  <cursor>
})

After install this plugin:

// from
it('test', () => {<cursor><CR>})
//to
it('test', () => {
<cursor>})

Do you have any idea how can I solve that?

Thank you. I'm able to use the native nvim-lsp thanks to your plugin.

Column value outside range

Hi,

I think this is an upstream issue in neovim's lsp, but maybe you know what's exactly causing it.

I'm getting this error with vimls.

Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/lsp/util.lua:641: Column value outside range

I get it when I type this:

function! s:map_item()

Once I close the parenthesis (or auto pairs does that for me, I tried both), Error appears. Error continues to appear if i continue typing abort.

Add support for neosnippets

(This issue follows the suggestions made here)

Hello, thanks for the plugin, I'm really impatient to use it as my daily driver !

The thing is that for now it does not support neosnippets, which would be great, is it possible to implement this, and how can I help on this ?

Allow for `additionalTextEdits` in completion items.

Is your feature request related to a problem? Please describe.
Current the built-in lsp support doesn't take into account that completions may have additionalTextEdits in them. I created a feature request for this already in nvim, and you can see the suggestion for a work around here. When playing around with it I realized that you already have something pretty similar to this with your confirmCompltion() function.

https://github.com/haorenW1025/completion-nvim/blob/7aedc744e2c7cd615a60b7b59d3e3c6a5491154e/lua/completion.lua#L51-L67

It'd be cool to also have this check for additionalTextEdits, and if so, apply them.

Describe the solution you'd like
Piggyback off confirmCompletion() and account for additionalTextEdits.

Describe alternatives you've considered
Locally listen for CompleteDone and have a function locally that does this.

errors without the proper config

I just used Plug without properly configuring the plugin (I know), yet it would be cool to avoid these errors:

|| Erreur dรฉtectรฉe en traitant function completion_treesitter#highlight_usages :
|| ligne    1 :
|| E5108: Error executing lua ...l/share/nvim/site/completion-treesitter/lua/ts_utils.lua:91: attempt to index a nil value
|| Erreur dรฉtectรฉe en traitant function completion_treesitter#highlight_usages :
|| ligne    6 :
|| E714: Liste requise
|| Erreur dรฉtectรฉe en traitant function completion_treesitter#highlight_usages :
|| ligne   13 :
|| E5108: Error executing lua ...l/share/nvim/site/completion-treesitter/lua/ts_utils.lua:91: attempt to index a nil value
|| Erreur dรฉtectรฉe en traitant function completion_treesitter#highlight_usages :
|| ligne   13 :
|| E714: Liste requise
|| Erreur dรฉtectรฉe en traitant function completion_treesitter#highlight_usages :
|| ligne   15 :
|| E121: Undefined variable: l:start
|| Erreur dรฉtectรฉe en traitant function completion_treesitter#highlight_usages :
|| ligne   15 :
|| E116: Arguments invalides pour la fonction empty
|| Erreur dรฉtectรฉe en traitant function completion_treesitter#highlight_usages :
|| ligne   15 :
|| E15: Expression invalide : !empty(l:start) && !empty(l:end) && l:start[0] == l:end[0] && ( g:complete_ts_highlight_at_point || !(( l:start[0] + 1 ) == l:cur_line && l:start[1] < l:cur_col && ( l:end[1] + 1 ) > l:cur_col) )

readme: several autocommands?

Hi, not a critical issue but the wording is confusing:

completion-nvim requires several autocommands set up to work properly

it seems to work fine without any autocommands; the autocommand is only required for use w/o lsp. diagnostic-nvim has the same wording, and also works fine w/o autocommands.

Pressing return on completion item doesn't trigger signature popup

Hi,

If I select a completion item then press left open bracket, the signature popup appears.

But if I select a completion item then press CR with g:completion_enable_auto_paren = 1 set, the parenthesis are added, but the signature popup does NOT appear.

I'm using the latest master pull, as of 2 hours ago.

Thanks!

.vimrc

let g:completion_chain_complete_list = {                                                                                                                                           
            \ 'default' : {                                                                                                                                                        
            \   'default': [                                                                                                                                                       
            \       {'complete_items': ['lsp', 'snippet']},                                                                                                                        
            \       {'mode': '<c-p>'},                                                                                                                                             
            \       {'mode': '<c-n>'}],                                                                                                                                            
            \   'comment': [],                                                                                                                                                     
            \   'string': []                                                                                                                                                       
            \   }                                                                                                                                                                  
            \ }                                                                                                                                                                    
let g:completion_enable_auto_hover = 0                                                                                                                                             
let g:completion_enable_auto_paren = 1                                                                                                                                             
let g:completion_enable_auto_popup = 1                                                                                                                                             
let g:completion_enable_auto_signature = 1                                                                                                                                         
let g:completion_enable_snippet = 0                                                                                                                                                
let g:completion_timer_cycle = 150                                                                                                                                                 
let g:completion_trigger_character = ['.', '::']                                                                                                                                   
let g:completion_trigger_keyword_length = 2

:verbose imap cr

i  <CR>        *@<Cmd>call completion#wrap_completion()<CR>

Treesitter integration

Neovim 0.5 will be integrated to treesitter through a lua api.

As the plugin is in lua, and focused for now on Neovim 0.5, it would be great to integrate the plugin with Treesitter, to provide syntax aware completion. This plus chained completion (#4) could allow us to bring, different combinations of completion mecanisms depending on the current syntax element.

Error vim.schedule lua callback, attempt to index a nil value

At random I get this error:

Error executing vim.schedule lua callback: .../nvim/pack/packager/start/completion-nvim/lua/source.lua:73: attempt to index a nil value

I can reproduce it 100% of the time by editing lua files, and for some other file types happens randomly. Note that I don't have lsp for lua set up, so maybe that's the issue.

This is my config:

let g:completion_chain_complete_list = {
      \ 'default': [
      \    {'complete_items': ['lsp', 'snippet', 'path']},
      \    {'mode': 'tags'},
      \    {'mode': 'keyn'},
      \    {'mode': '<c-p>'},
      \  ]}

pyls completion not working

I've tried the following with a minimal example.
nvim -u test.vim pyproj/test.py

test.vim:

let g:python3_host_prog = '/home/inco/.pyenv/shims/python'
call plug#begin('~/.vim/plugged') 
    Plug 'neovim/nvim-lsp'
    Plug 'haorenW1025/completion-nvim'
call plug#end()
lua require'nvim_lsp'.pyls.setup{on_attach=require'completion'.on_attach}
au Filetype python setl omnifunc=v:lua.vim.lsp.omnifunc
" 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

Checkhealth tells me plys and everything else works.
I've created a virtual environment for neovim. Maybe it helps to reproduce what's wrong.

ArchLinux specific:

# pacman -S pyenv
yay -S pyenv-virtualenv

Create and activate virtual environment for python 3.7

pyenv install 3.7.7
pyenv virtualenv 3.7.7 neovim3
pyenv activate neovim3

Install related packages for neovim and pyls

pip install --upgrade pip
pip install neovim
pip install 'python-language-server[all]'
pip install -U setuptools
pip install pyls-mypy pyls-isort pyls-black
python -m pyls --help
which python

Add the vitrual python path to the neovim host config

let g:python3_host_prog = '/home/inco/.pyenv/shims/python'

When i type no autocompletion starts.
I guess import should already expandable on imp.

PS: When i use your current configuration the completion on .vim files works perfectly.

[resolved] setting up without an plugin manager

Since I do not use any plugin manager I did the default procedure for installing a plugin with the build in plugin loader capabilities provided by neovim.

When neovim does the initial loading of the packages, even though they are correct on the path as it appears to me, it can not resolve the modules.
So only after neovim has completed its startup the modules can correctly be resolved.
This implies a warning each time starting nvim.

To resole this, I did the following steps - I am creating an issue instead of a pull request, since it appears to me that this is an issue of either neovim itself nor of the lsp-config's but your plugin.
be an issue of neovim, already reported:

neovim/neovim#11409
Lua: search 'packpath' from require() without :packloadall

Anyway, here I document my steps:

additonal steps (no plugin manager)

  • Before setting up nvim-lsp in your init.vim: Prepare the runtimepath with :packloadall as described as an (probably temporarily) workaround in the mentioned issue above. Thats it.
  • When setting up without a plugin manager nvim will not find the module on
    first load. So you need to prepare the package.path for making all lua-files accessible:
    local tmp = package.path
    local git_plug_path = '/.local/share/nvim/site/pack/git-plugins/start'
    package.path = vim.loop.os_homedir() .. git_plug_path .. '/completion-nvim/lua/?.lua'
    local completion = require 'completion'
    package.path = tmp

Same thing is required for diagnostic-nvim. Note that you need semicolons for multiple paths. It works on the end of the string aswell '/completion-nvim/lua/?.lua;'

Signature help floating window does not close when removing parentheses

Hi, well done for this plugin, it's excellent!

I have an issue with the signature help floating window that does not disappear is some cases. The main one happens when I add parentheses when calling a method or function and then remove these parentheses.

For example, in javascript calling console.log() makes the floating window appears, removing the () does not make it disappear. It only goes away when I exit the insert mode.

I suspect it comes from this line https://github.com/haorenW1025/completion-nvim/blob/master/lua/signature_help.lua#L84 but I'm not enough familiar with vim scripting or lua to come up with the appropriate fix.

Test validity of highlight ranges

Hi guys. Following on #52 that had an issue with vimls providing -1 as start/end of highlight range, I had a similar bug on pyls.

I'm working on a codebase I didn't write of a somewhat beginner python developer, and I had a sample similar to the following:

if True:
    '''
    some text
    '''
    print("hello_world")

On this sample of code (that shouldn't happen), pyls sends:

{
    code = "W0105",
    message = "[pointless-string-statement] String statement has no effect",
    range = {
      end = {
        character = 8,
        line = 3
      },
      start = {
        character = -1,
        line = 3
      }
    },
    severity = 2,
    source = "pylint"
  }

The problematic line here is start.character = -1. This value goes to the function responsible for highlighting, that throws:

Error executing vim.schedule lua callback: ...are/nvim/plugged/diagnostic-nvim/lua/diagnostic/util.lua:17: Column value outside range

Please note that this function is a copy from nvim's runtime, so without the plugin, it's neovim's identical function that throws that error:

Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/lsp/util.lua:628: Column value outside range

So #52 was solved by a server-side issue (that was extremely quickly fixed on vimls side), I guess this should be the preferred way to solve this issue as well (I will forward it to pyls).
However, as other cases like this one might appear, could it be interesting to find a non-intrusive way to log this error, as it was actually spamming my messages and made coding quite difficult.

P.S: I'm posting the issue here and not in diagnostic-nvim as it follows #52.

Floating windows are focusable

Hi,

is there a reason to enable focus on hover windows?
It happens to me sometimes to focus it and then i need to close it manually.

Sort suggestions by kind priority

Hi! First of all, thanks for this nice plugin. Works neat!

When I'm programming in JavaScript, when suggestion for objects appear (e.g. after typing obj.), many variables show up in the suggestions, most are of kind File, while the ones of kind Field (the object fields) get lost throughout all suggestions.

Now, I'm not sure what's the ideal solution, but it would be nice if kinds like Field had priority over ones like File, so the first suggestions that show up are the object fields.

Understanding NeoVim completion and your plugin

Would like to use NeoVim LSP completion. Came across the official docs and your solution which seems to be the only completion plugin using the native LSP client.

I don't know much about NeoVim completions so I'm just trying to find my way. I have a couple of questions:

  1. What are the differences between the setup in the core docs and your plugin?
  2. NeoVim seems to have multiple completions (word, line, file, omni). It seems like any completion plugin, including yours, takes over the word completion and makes it behave more like omni but I've noticed in your dotfiles that you're still using settings relating to omni. Does this mean omni is still relevant and what's the relationship between the two?

Would really appreciate some guidance, in the meantime I'll continue to educate myself.

Support for function argument snippets (recent Neovim commit)

Hi,

It seems that one of the latest Neovim commits (neovim/neovim@e6cfc1b) adds support for returning function argument snippets, which completion-nvim doesn't seem to have support for? (see pic).

Would it be a lot of work for you to implement support for this?

Or maybe there's some other plugin I can use to handle these? I tried Ultisnips but that didn't seem to work.

Thanks!

Screenshot 2020-04-22 at 08 01 10

ultisnip error

Setting let g:completion_enable_snippet = 'UltiSnips' without ultisnips triggers the following error:

onnue : UltiSnips#SnippetsInCurrentScope

in general i dont mind these but due to the nature of the plugin, vim loops over the error and it becomes hard to quit. Maybe it could ignore the error and provide a check via checkhealth (see :help health-dev).

Completion source sorting

Hi,

When i initially started using the plugin with ultisnips, my snippets completion was sorted ok. Now, i noticed it's not sorted correctly. Is this something that is handled by completion-nvim or it's just printed out how ultisnips returns it?

Here's the screenshot:
screenshot

I would expect items to be sorted like this:

cl
cla
clac
clax
clearq
click
clone

Path completion of files/directories with spaces in the name

Hi @haorenW1025 , firstly thank you for super completion plugin. I use it on daily basis for home and work tasks.

Unfortunately, when i try to complete path for example: "~/Directory/With spaces/", the Directory part is suggested correctly but completion of inner directory is divided into two suggestions: 'With', 'spaces'.

I tried look to source code and it seems that you use system ls command to retrieve list of files/directories and after that you match listed files by %S+ which matches only one word without spaces. Pity i can't help since i don't know lua language.

Also sorry for my English language :)

Add ability to leave confirm key empty

I'd like to not have confirm key set and just go through the menu using the default <C-n> & <C-p>.
Currently setting g:completion_confirm_key = "" causes an error, It would be great if this disabled the mapping instead.

Docked signature window

Hi, thank you for this plugin! Would it be possible to implement a setting similar to let g:float_preview#docked = 1 on ncm2?

Odd behavior after multiples tabs

When using the recommended settings in the readme in order to use <Tab> to filter through the completion options, I get odd behavior when I filter through the completion items only if there is something that already exists where I'm trying to completion. For example:

import jav@@

At this point above, I can circulate through the options with no issue, and select the one that I want.

After I complete java, if I think attempt to continue to completion, I get odd behavior when doing completions:

import java.ti@@

Here is a couple gifs of the behavior I'm referring to:

2020-05-14 11 07 20

2020-05-14 10 58 03

How to reproduce
This is happening with Metals. Probably the easiest way to reproduce this would be to do the following:

  • LspInstall metals, which which will install metals.
  • Then you can nvim-metals which will provide you some necessary commands for a Scala workspace.
  • You can use this minimal project.
  • Just open the build.sbt file, nvim build.sbt. Then you can issue a :BuildImport command which will import the build.
  • Then navigate to any Scala file in the project and attempt to do a package import like I did in the gif.

Expected behavior
I would expect the completions to work the same if it is a base completion or one coming after a .

completion_chain_complete_list error on startup

Version info (latest versions as of today):

NVIM v0.5.0-05fd64777
LuaJIT 2.0.5
completion-nvim: d9be95662fddaee96d59c1322c751b7dffcc28cf

Full error output:

Error detected while processing /Users/matt.bailey/test.vim:
line    5:
E5108: Error executing lua ...iley/.config/nvim/plugged/completion-nvim/lua/source.lua:117: Key not found: completion_chain_complete_list
Press ENTER or type command to continue

testing vimrc (as suggested):

call plug#begin('~/.config/nvim/plugged')
    Plug 'neovim/nvim-lsp'
    Plug 'haorenW1025/completion-nvim'
call plug#end()
lua require'nvim_lsp'.sumneko_lua.setup{on_attach=require'completion'.on_attach}
au Filetype lua setl omnifunc=v:lua.vim.lsp.omnifunc
" 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

[Feature] Show complete item "info" as signature

Hi,

what do you think about showing selected complete item info property as signature beside the autocompletion, in situations where it is not empty? I have a custom completion that provides info with some details, but i'm not sure how to show it.

Chained completions support

I don't know if you've ever tried mucomplete, but the completion mecanism there is really nice, and only using built-in features.

The way it works is it tries each completion method in a predefined list, and offers you :

  • The first which work as current completion method
  • A way to navigate between completion methods and select the one you want

It is really useful for two reasons :

  • Most of the time you only want syntaxic completion, and this only, without snippets which are filling completion list
  • When using completion in another way (snippets for example), you don't really know their name.

lua callback error: 'make_text_document_params' (a nil value)

Hi,

the plugin works great on my local machine. But after setting it up on ssh (with fresh installs of dotnet and nvim-lsp + pyls_ms) I continuously run into

/nvim/plugged/completion-nvim//lua/completion/hover.lua:344: attempt to call field 'make_text_document_params' (a nil value)

The LSP is working (linting, vim.lsp.buf.'function' for renaming, go-to definition, hover, etc.), but - as you'd expect from the error - hover at completion does not work.

Many thanks for your help!

Versions:
NVIM v0.5.0-477-gf9055c585
dotnet - v3.1.3 SDK

"Pattern not found" message constantly being sent on new text

Hey, Love the plugin!

Having a small problem that I'm not sure why this is happening. Whenever I type something that doesn't exist in the current buffer (or as a valid completion) I get a message on every keystroke like

|| Pattern not found
|| Pattern not found
|| Pattern not found
|| Pattern not found

Is there some configuration option you know of that I might have missed?

Completeopt is what is recommended in the setup guide.

Thanks

[Feature Request] Customizing completion kind labels

It would be nice if, similar to coc.nvim, there was an easy way to customize the labels used for various kinds of items in completion results. The most common use case of this is probably wanting to use icons rather than names for the labels.

Completion menu not displaying

I'm attempting to make the switch from deoplete-lsp to this plugin (nice work, by the way), but I'm having some difficulties getting completion working.

In a mostly clean (no plugins, some config) runtime of nvim v0.5.0-482-ga6071ac04, the completion menu doesn't appear as I type. I have verified that I have an attached client, unlike the problem described in #46, and I can confirm that my language server is sending responses to completion requests. There are two things that I notice:

  1. The completion trigger characters aren't being loaded from the language server, despite them being present when I call :lua print(vim.inspect(vim.lsp.buf_get_clients()))
  2. If I manually set the completion trigger characters, the completion list fails to parse with the following error:Error executing vim.schedule lua callback: shared.lua:486: s: expected string, got userdata

This particular language server works with deoplete-lsp and another VSCode client, but just in case it could be useful, the completion response is attached below.

If I can provide more info please let me know.

Content-Type: application/vscode-jsonrpc; charset=utf8
Content-Length: 4292

{"id":10,"result":{"isIncomplete":false,"items":[{"label":"getUri","kind":2,"detail":"public getUri(): string","documentation":"","sortText":null,"filterText":null,"insertText":"getUri","textEdit":null,"additionalTextEdits":null,"command":null,"data":null,"insertTextFormat":1},{"labe
l":"getSource","kind":2,"detail":"public getSource(): string","documentation":"","sortText":null,"filterText":null,"insertText":"getSource","textEdit":null,"additionalTextEdits":null,"command":null,"data":null,"insertTextFormat":1},{"label":"getNodes","kind":2,"detail":"public getNod
es(): array","documentation":"\/**\n * @return NodeAbstract[]\n *\/","sortText":null,"filterText":null,"insertText":"getNodes","textEdit":null,"additionalTextEdits":null,"command":null,"data":null,"insertTextFormat":1},{"label":"getNodesAtCursor","kind":2,"detail":"public getNodesAtC
ursor(LanguageServer\\CursorPosition $cursorPosition): array","documentation":"\/**\n * @return NodeAbstract[]\n *\/","sortText":null,"filterText":null,"insertText":"getNodesAtCursor","textEdit":null,"additionalTextEdits":null,"command":null,"data":null,"insertTextFormat":1},{"label"
:"getNodesBesideCursor","kind":2,"detail":"public getNodesBesideCursor(LanguageServer\\CursorPosition $cursorPosition): array","documentation":"\/**\n * @return NodeAbstract[]\n *\/","sortText":null,"filterText":null,"insertText":"getNodesBesideCursor","textEdit":null,"additionalText
Edits":null,"command":null,"data":null,"insertTextFormat":1},{"label":"getClassName","kind":2,"detail":"public getClassName(): string","documentation":"","sortText":null,"filterText":null,"insertText":"getClassName","textEdit":null,"additionalTextEdits":null,"command":null,"data":nul
l,"insertTextFormat":1},{"label":"getMethod","kind":2,"detail":"public getMethod(string $methodName): PhpParser\\Node\\Stmt\\ClassMethod","documentation":"","sortText":null,"filterText":null,"insertText":"getMethod","textEdit":null,"additionalTextEdits":null,"command":null,"data":nul
l,"insertTextFormat":1},{"label":"getClassProperty","kind":2,"detail":"public getClassProperty(string $propertyName): PhpParser\\Node\\Stmt\\Property","documentation":"","sortText":null,"filterText":null,"insertText":"getClassProperty","textEdit":null,"additionalTextEdits":null,"comm
and":null,"data":null,"insertTextFormat":1},{"label":"findNodes","kind":2,"detail":"public findNodes(string $class): array","documentation":"\/**\n * @return NodeAbstract[]\n *\/","sortText":null,"filterText":null,"insertText":"findNodes","textEdit":null,"additionalTextEdits":null,"c
ommand":null,"data":null,"insertTextFormat":1},{"label":"searchNodes","kind":2,"detail":"public searchNodes(callable $criteria): array","documentation":"\/**\n * @return NodeAbstract[]\n *\/","sortText":null,"filterText":null,"insertText":"searchNodes","textEdit":null,"additionalText
Edits":null,"command":null,"data":null,"insertTextFormat":1},{"label":"getUseStatements","kind":2,"detail":"public getUseStatements(): array","documentation":"\/**\n * @return NodeAbstract[]\n *\/","sortText":null,"filterText":null,"insertText":"getUseStatements","textEdit":null,"add
itionalTextEdits":null,"command":null,"data":null,"insertTextFormat":1},{"label":"getConstructorNode","kind":2,"detail":"public getConstructorNode(): PhpParser\\Node\\Stmt\\ClassMethod","documentation":"","sortText":null,"filterText":null,"insertText":"getConstructorNode","textEdit":
null,"additionalTextEdits":null,"command":null,"data":null,"insertTextFormat":1},{"label":"getNamespace","kind":2,"detail":"public getNamespace(): string","documentation":"","sortText":null,"filterText":null,"insertText":"getNamespace","textEdit":null,"additionalTextEdits":null,"comm
and":null,"data":null,"insertTextFormat":1},{"label":"getCursorPosition","kind":2,"detail":"public getCursorPosition(int $line, int $character): LanguageServer\\CursorPosition","documentation":"\/**\n * Calculate the cursor position relative to the beginning of the file.\n *\n * This
 method removes all characters proceeding the $character at $line\n * and counts the total length of the final string.\n *\/","sortText":null,"filterText":null,"insertText":"getCursorPosition","textEdit":null,"additionalTextEdits":null,"command":null,"data":null,"insertTextFormat":1}
]},"error":null,"jsonrpc":"2.0"}Content-Type: application/vscode-jsonrpc; charset=utf8

[Feature request] Relative path completion

Hi,

would you consider adding a relative file path completion as an optional source?
Something like this.

I tried adding it myself, but since i don't know lua, everything turned out to be calls to vimscript.

[Q] Adding additional completion sources

Thanks for your nice and lightweight plugin!

It realy works great with nvim-lsp. I would like to integrate additional completion sources like other words in the current or other buffers, or from different tmux panes. Is there already support for these kind of sources? How can I include these?

completion-nvim breaks omnicomplete

I have a setup where I use autocompletion for lsp suggestions (latex-lsp/texlab), but also rely on omnicompletion from a filetype plugin (lervag/vimtex), which has better (but slower) substring matching on menu strings as well.

However, this no longer works when completion-nvim is active; if I press <c-x c-o>, the omnicomplete suggestions pop up briefly, but then vanish again. This only happens if the typed string does not match any autocomplete candidates; if it does (because some candidates start with the string), the auto-complete suggestions are correctly replaced with the omnicomplete ones.

(This doesn't happen with other autocomplete plugins like ncm2 or asyncomplete.)

Cursor jumps to the end when completing

While i was setting up vim, i noticed that cursor jumped to the end for some characters. You can see in gif what is my configuration.
Note that i tried both with and without auto pairs plugin, but still same.
Here's the gif:

completion

lua callback erorr

I may be totally missing something here, but I'm continually getting the same error, and I'm unsure what's causing it. I tried using the minimal test.vim that you have in your wiki, and I still get the error.

I installed metals using the LspInstall metals command outlined in nvim-lsp and the only thing I have in my minimal test.vim file is different is the following line changed for metals.

lua require'nvim_lsp'.metals.setup{on_attach=require'completion'.on_attach}

When I open a .scala file, I can see in the server trace file that everything has started as expected but the moment I start typing I am greeted with this:

Error executing vim.schedule lua callback: /Users/ckipp/.vim/plugged/completion-nvim/lua/utility.lua:30: attempt to call field 'tbl_filter' (a nil value)

Any insight would be greatly appreciated.

I'm on:

  • MacOS
  • iTerm2
  • NVIM v0.5.0-3d1531a

Ultisnips does not expand

I've been using coc.nvim for a long time. And I really like it's behaviour
That's why I use set completeopt=menuone,noinsert instead of completeopt=menuone,noinsert,noselect. The problem now that ultisnips does not work with these settings, snippets don't expand.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.