Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mucomplete fail to complete correctly includes files for c/c++ #177

Open
lbiaggi opened this issue May 9, 2020 · 12 comments
Open

mucomplete fail to complete correctly includes files for c/c++ #177

lbiaggi opened this issue May 9, 2020 · 12 comments

Comments

@lbiaggi
Copy link

lbiaggi commented May 9, 2020

Hi, When using mucomplete with languageclient-neovim, can't complete correctly the includes or suggest them correctly.

Steps to reproduce:

  1. Configure ccls or clangd with languageclient-neovim
  2. Configure mucomplete as described in wiki
  3. Open a new file and try to include anything e.g: #include <std<tab>> it fails to identify correctly the file suggested by LC or #include <stdio.<tab> When dot is inserted, it tries to complete the file name incorrectly becoming #include <stdio.stdio.h>
@lifepillar
Copy link
Owner

lifepillar commented May 10, 2020

#include <std<tab>> it fails to identify correctly the file

If , instead of typing Tab, you type CTRL-X CTRL-O, does it complete correctly?

@lbiaggi
Copy link
Author

lbiaggi commented May 11, 2020

Yes, it does
image

@lifepillar
Copy link
Owner

lifepillar commented May 12, 2020

Ok. Have you read :help mucomplete-compatibility, specifically the paragraph about LanguageClient-neovim? Does that help?

@lbiaggi
Copy link
Author

lbiaggi commented May 13, 2020

Nope, I was already using them

My current config is:

let g:mucomplete#completion_delay = 100
let g:mucomplete#reopen_immediately = 0
set complete=.,w,b,u,k
set shortmess+=c
let g:mucomplete#force_manual = 1
let g:mucomplete#enable_auto_at_startup = 1
let g:mucomplete#can_complete = {}
let g:mucomplete#chains = {}
let g:mucomplete#chains.default = ['omni', 'c-n', 'path', 'tags']
let g:mucomplete#empty_text_auto = 0
let s:cpp_cond = { t -> (t =~# '\m\(\k\|)\|]\)\%\(->\|::\|\.\)$') || (g:mucomplete_with_key && t =~# '\m\k\k$') }
let s:c_cond = { t -> (t =~# '\m\(\k\|)\|]\)\%\(->\|\.\)$') || (g:mucomplete_with_key && t =~# '\m\k\k$') }
let g:mucomplete#can_complete.cpp = { 'omni': s:cpp_cond }
let g:mucomplete#can_complete.c = { 'omni': s:c_cond }
let g:mucomplete#chains.cpp = ['path','omni', 'defs', 'c-n', 'tags', 'uspl']
let g:mucomplete#chains.c = ['omni', 'defs', 'c-n', 'path', 'tags', 'uspl']
let g:mucomplete#always_use_completeopt = 1

I installed deoplete, and there the LC suggests auto complete correctly, not sure if that helps anything,

image

@lifepillar
Copy link
Owner

Ok, thanks for the configuration details. I'll try to reproduce your issue and come back to you.

@lifepillar
Copy link
Owner

lifepillar commented May 21, 2020

I have tried with clangd, but I cannot reproduce your issue (using macOS here). I am not offered any completion after #include <std or #include <stdio. by either Mucomplete or CTRL-X CTRL-O, and when CTRL-X CTRL-O gives completions, MUcomplete does as well.

I suggest that you start with a minimal configuration, by adapting troubleshooting_vimrc.vim (inside MUcomplete's folder) and add settings one at a time to find the culprit. I also suggest that you add MUcompleteNotify 2 to your settings to see which completion method is used and/or let b:mucomplete_chain = ['omni'] in your C++ buffer to make sure that only OmniCompletion is active.

You mention that you are editing a new buffer. Does it make a difference if you open a file instead?

Have you installed only LanguageClient-neovim or do you have other completion plugins?

And which version of Vim?

@lbiaggi
Copy link
Author

lbiaggi commented May 21, 2020

You mention that you are editing a new buffer. Does it make a difference if you open a file instead? No, it does not. Clangd or CCLS needs the compile_commands.json to give hints properly

Have you installed only LanguageClient-neovim or do you have other completion plugins? Yes, I just use LanguageClient-neovim for LSP (C/C++ (CCLS) and Tex (texlab) and for auto complete I use your plugin and was using deoplete (to compare) if something went wrong.

And which version of Vim? Neovim

NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.3/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compilado por builduser

Features: +acl +iconv +tui
See ":help feature-compile"

    arquivo vimrc de sistema: "$VIM/sysinit.vim"
            padrão para $VIM: "/usr/share/nvim"

Run :checkhealth for more info

I attached my configuration files (mucomplete, deoplete and ccls stuff)

nvimrc_deoplete.txt

nvimrc_mucomplete.txt

settings.json.txt

Steps I did to test:

1 - cloned my repo: https://invent.kde.org/lbiaggi/plasma-firewall
2 - copied .nvimrc (mucomplete or deoplete) and settings.json to git folder
3 - executed cmake and targeted /home/lbiaggi/kde/build/plasma-firewall as build folder (I use CMake4Vim plugin)
4 - open a random file and tried to include something with deoplete I obtain suggests from LC like stdio.h, stdlib.h and with your plugin there is no suggestion.

Not sure what deoplete to show them it says that come from LC.
Deoplete Image (using nvimrc_deopletetxt as .nvimrc)
image
image

Mucomplete:
image
image

Question: if it comes from LC the mucomplete would be able to see complete it right?

@lifepillar
Copy link
Owner

Question: if it comes from LC the mucomplete would be able to see complete it right?

MUcomplete does the same as pressing CTRL-X CTRL-O; it doesn't care which omni-completion function is used.

I'll try to reproduce your issue with the additional configuration you have posted. In the meantime, can you please try the following:

  • :MUcompleteAutoOff
  • Type #include <stdio. followed by CTRL-X CTRL-O. Is the completion menu different from the one in the screenshot you'posted?

If it is the same, can you try MUcomplete with a very high value for g:mucomplete#completion_delay? Like 500 or even 2000. Just to rule out a synchronization issue.

@lbiaggi
Copy link
Author

lbiaggi commented May 22, 2020

Sure,

I did few more testing and yes the MUComplete behavior is correctly, I mean the omnifunc does not trigger with std only.

What I still do not understand is why Deoplete is showing what I was expecting "correctly"? Maybe related with this https://github.com/autozimu/LanguageClient-neovim/blob/next/rplugin/python3/deoplete/sources/LanguageClientSource.py#L17

@lbiaggi
Copy link
Author

lbiaggi commented May 23, 2020

Should I close it or we investigate why mucomplete does not behave like deoplete?

@lifepillar
Copy link
Owner

I think that Deoplete aggregates entries from different sources. If you can find where those entries come from (e.g., ctags, Vim’s keyword completion, …), you should be able to get roughly the same with MUcomplete.

You may leave this open for now.

@lbiaggi
Copy link
Author

lbiaggi commented May 23, 2020

hmm, did you check LanguageClientSource.py? There it defines [LC] as its identifier, in my screenshot with deoplete, it says it came from [LC]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants