nvim-lua / completion-nvim

A async completion framework aims to provide completion to neovim's built in LSP written in Lua
Apache License 2.0
973 stars 78 forks source link

trigger completion on /** #80

Open jnvrs opened 4 years ago

jnvrs commented 4 years ago

The intelephense language server can generate doc blocks with auto completion on /**.

If i use the default neovim lsp omnifunc i get the doc block suggested. Completion-nvim however does not trigger any completion on /**

i tried let g:completion_trigger_character = ['/**'], but it did not make any difference

can i trigger the completion menu manually ? the default omnifunc does not process textEdits ?

haorenW1025 commented 4 years ago

There is no suggest items because completion in comments are closed by default. You can enable it by

let g:completion_chain_complete_list = {
            \ 'php' : {
            \   'default': [
            \       {'complete_items': ['lsp', 'snippet']},
            \       {'mode': '<c-p>'},
            \       {'mode': '<c-n>'}],
            \   }
            \  }
jnvrs commented 4 years ago

thanks, this worked in combination with: let g:completion_trigger_character = ['*']

while selecting the item in the completion menu i get the following error:

Error executing vim.schedule lua callback: Vim:E731: using Dictionary as a String

the same happens with the builtin omnifunc

haorenW1025 commented 4 years ago

Hmm if it also happens with the builtin omnifunc, I suggest opening an issue on neovim cause that should be a problem on their side.

jnvrs commented 4 years ago

i have testet this, if i don't attach completion-nvim, i do not get the message

haorenW1025 commented 4 years ago

Okay then can you try updating to the latest master branch of neovim and see if it solve your issue? Similar things happen in #73.

jnvrs commented 4 years ago

upgrading nvim has no effect on the issue, if i use omnifunc the message appears as soon as i select ne completion in the menu

haorenW1025 commented 4 years ago

Could you give a reproduce step and your testing minimal init.vim? I can't reproduce on my side.

jnvrs commented 4 years ago

the doc block completion only works with a license key.

the completion does still work,

i made a little video to better show this: Peek 2020-05-26 08-12 the moment i select the "snippet" and it appears unprocessed the message comes up.

could you give me a hint, what happens on the selection ? i could try to see if i find the problem

haorenW1025 commented 4 years ago

Hmm I have similar issues with lua language server too and this seems to happen when snippet have multiple lines. But I can reproduce this issue on my side without attaching to completion-nvim. I'm not getting the same suggestion when using intelephense though(not familiar with php), is there some setting I need to set to reproduce this issue?

could you give me a hint, what happens on the selection ? i could try to see if i find the problem

Only thing completion-nvim tries to do on the selection is trying to open a hover window, maybe you can try if this can be reproduced when let g:completion_enable_auto_hover = 0

jnvrs commented 4 years ago

let g:completion_enable_auto_hover = 0 has no effect.

I'm not getting the same suggestion when using intelephense though(not familiar with php), is there some setting I need to set to reproduce this issue?

you need to own a license to get this completion.

i'll try to poke in completion-nvim source and can see if i find the problem. But it seems to be a problem with multilines, as this is the only completion with multilines, all other completions do not produce this message

haorenW1025 commented 4 years ago

you need to own a license to get this completion.

Oh okay...hopefully you can get a good result. The code was a bit messy though.. Feel free to ask me if anything blocks you.

jnvrs commented 4 years ago

the problem seem to occur with this line https://github.com/haorenW1025/completion-nvim/blob/704f9a3d7e8a4399016e86c8fea2e025b6830388/lua/source.lua#L127

i tried to call vim.fn.match with the same params on the cmd but did not get any error

haorenW1025 commented 4 years ago

Hmm this line shouldn't cause any issue cause it's moved from neovim source directly.

i tried to call vim.fn.match with the same params on the cmd but did not get any error

I don't get it. If it didn't get any error, wouldn't it means that this line should be correct?

jnvrs commented 4 years ago

I don't get it. If it didn't get any error, wouldn't it means that this line should be correct?

Yep, but i am able to reproduce this: /*^@*/ if i do omnicompletion on that line or autocompletion is triggered i get that error

haorenW1025 commented 4 years ago

Can you double check can this be reproduced without completion-nvim? Cause when you look at neovim's source code in lsp.lua you'll find they have the same line in function lsp.omnifunc

 local textMatch = vim.fn.match(line_to_cursor, '\\k*$') 
jnvrs commented 4 years ago

you are right, it does not happen on the initial selection, but if i try to call omnicompletion again i get the same error.

So the problem seems to be in neovim, but this would also mean, that completion-nvim calls the autocompletion after selecting an item in the completion menu, right?

haorenW1025 commented 4 years ago

Hmm the autocompletion should only be called if you hit extra keystroke, so that's quite weird. I'll look into it.

spimanov commented 4 years ago

Hello! What is the reason of using \\k$*? I have several snippets like #ifdef, #incl and etc. The regexp prevents to use such names, so I've changed it locally by \\S$* - now everything works well (for me :)) But I can't understand the reason of the \k.