ccls icon indicating copy to clipboard operation
ccls copied to clipboard

Autocompletion does not work in *.H files while works in *.C file

Open pBlasiak opened this issue 2 years ago • 3 comments

Observed behavior

I am using OpenFOAM C++ library. I followed these instructions https://openfoamwiki.net/index.php/HowTo_Use_OpenFOAM_with_Visual_Studio_Code After the running the vscode-settings I have the following setting.json file: ` { "[cpp]": { "editor.wordBasedSuggestions": true, "editor.suggest.insertMode": "replace", "editor.semanticHighlighting.enabled": true }, "ccls.cache.directory": "/home/przemek/OpenFOAM/OpenFOAM-v2106/build/linux64GccDPInt64Opt/ccls-cache",

"ccls.misc.compilationDatabaseDirectory":
"/home/przemek/OpenFOAM/OpenFOAM-v2106/build/linux64GccDPInt64Opt",

"C_Cpp.default.compileCommands":
"/home/przemek/OpenFOAM/OpenFOAM-v2106/etc/openfoam wmake -with-bear -s -j",

"C_Cpp.autocomplete": "Disabled",
"C_Cpp.errorSquiggles": "Disabled",
"C_Cpp.formatting": "Disabled",
"C_Cpp.intelliSenseEngine": "Disabled",
"files.associations": {
    "*.H": "cpp",
    "*.C": "cpp",
 }

}

`

When I open folder with my project in VSC evry file is recognized by the ccls. In the main file with *.C extension autocompletion of methods after writing "object." works very well. However, in the *.H files it does not see anything.

Expected behavior

Autocompletion in header files (*.H) works.

Steps to reproduce

I think it is general issue and no reproduce steps are necessary. The question is how to enable autocompletion in *.H files. I have tried to use .ccls file with such settings but it does not work: %h -x %h c++-header

System information

  • ccls version: v0.1.29
  • clang version: 10.0.0-4ubuntu1
  • OS: Ubuntu 20.04
  • Editor: visual studio code
  • Language client (and version): C++

pBlasiak avatar Dec 14 '22 13:12 pBlasiak

I am having a similar issue. My problem is best described in the issue from another cpp extension here: https://github.com/microsoft/vscode-cpptools/issues/4662 The RCA seems to be that vscode does not automatically trigger completions for macro definitions. But the extension does not support manual completion either.

PandaTinker avatar Dec 14 '22 18:12 PandaTinker

I think in macros it is more difficult situation. OpenFOAM has specific H files. Sometimes they are typical h file as a class header, sometimes it contains frequently used code, sometimes just includes other H files. The question is if it would be typical h file or hpp, does ccls supports autocompletion in such files? Is it possible to add this feature to H files?

pBlasiak avatar Dec 15 '22 13:12 pBlasiak

Hi, try removing the key-pair value, "ccls.cache.directory". This is because for some bizarre reason, ccls will index the header files inside of the cache directory, instead of the header files inside of the includes (or wherever you put your header files) directory.

DuckyShine004 avatar Jan 13 '24 04:01 DuckyShine004