tweekmonster / deoplete-clang2

MIT License
90 stars 17 forks source link

Paths to headers get completed but everything else does not #15

Closed alexpyzhianov closed 7 years ago

alexpyzhianov commented 7 years ago

Hey! I'm just starting out with C++ and making a small project with libcinder. I build it with cmake configuration that Cinder provides. Everything works fine but I can't make auto completion work.

What's interesting is that when I type #include "(...) a dropdown shows me a bunch of vaild options, including Cinder libs like:

#include "cinder/gl/gl.h"
#include "cinder/gl/Batch.h"

But when I try to see stuff in the included namespace typing something like gl::(...)... Nothing. I see only suggestions from buffer source.

My ./compile_commands.json looks like this:

[
{
  "directory": "/home/alex/projects/fixation",
  "command": "/usr/bin/c++  -DFT2_BUILD_LIBRARY -DFT_DEBUG_LEVEL_TRACE -D_GLFW_X11 -D_GLFW_GLX -D_GLFW_USE_OPENGL -D_GLIBCXX_USE_CXX11_ABI=0 -D_UNIX -isystem /home/alex/repos/Cinder/include  -g   -std=c++14 -o CMakeFiles/Fixation.dir/src/Fixation.cpp.o -c /home/alex/projects/fixation/src/Fixation.cpp",
  "file": "/home/alex/projects/fixation/src/Fixation.cpp"
}
]

After running cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 my project folder looks like this:

./Debug
./Debug/Fixation
./Makefile
./cmake_install.cmake
./structure.txt
./assets
./CMakeCache.txt
./compile_commands.json
./CMakeLists.txt
./CMakeFiles
./CMakeFiles/cmake.check_cache
./CMakeFiles/progress.marks
./CMakeFiles/CMakeTmp
./CMakeFiles/feature_tests.bin
./CMakeFiles/3.8.2
./CMakeFiles/3.8.2/CompilerIdC
./CMakeFiles/3.8.2/CompilerIdC/CMakeCCompilerId.c
./CMakeFiles/3.8.2/CompilerIdC/tmp
./CMakeFiles/3.8.2/CompilerIdC/a.out
./CMakeFiles/3.8.2/CMakeDetermineCompilerABI_CXX.bin
./CMakeFiles/3.8.2/CMakeCXXCompiler.cmake
./CMakeFiles/3.8.2/CMakeDetermineCompilerABI_C.bin
./CMakeFiles/3.8.2/CMakeSystem.cmake
./CMakeFiles/3.8.2/CMakeCCompiler.cmake
./CMakeFiles/3.8.2/CompilerIdCXX
./CMakeFiles/3.8.2/CompilerIdCXX/CMakeCXXCompilerId.cpp
./CMakeFiles/3.8.2/CompilerIdCXX/tmp
./CMakeFiles/3.8.2/CompilerIdCXX/a.out
./CMakeFiles/Makefile.cmake
./CMakeFiles/feature_tests.c
./CMakeFiles/Fixation.dir
./CMakeFiles/Fixation.dir/progress.make
./CMakeFiles/Fixation.dir/build.make
./CMakeFiles/Fixation.dir/link.txt
./CMakeFiles/Fixation.dir/flags.make
./CMakeFiles/Fixation.dir/depend.make
./CMakeFiles/Fixation.dir/src
./CMakeFiles/Fixation.dir/cmake_clean.cmake
./CMakeFiles/Fixation.dir/DependInfo.cmake
./CMakeFiles/TargetDirectories.txt
./CMakeFiles/CMakeDirectoryInformation.cmake
./CMakeFiles/Makefile2
./CMakeFiles/feature_tests.cxx
./CMakeFiles/CMakeOutput.log
./src
./src/Fixation.cpp

Any help would be much appreciated. Thank you!

alexpyzhianov commented 7 years ago

Quick update. Still not resolved, deoplete-clang picks my compile_commands.json but is very slow. My clang is 4.0.0 maybe major version has something to do with it

tweekmonster commented 7 years ago

This may be related to #14. If you don't think it is, I'm fairly clueless when it comes to C++, unfortunately.

tweekmonster commented 7 years ago

Actually I think I see the issue, but I don't really have any means to confirm it. Could you try adding this:

elif context.get('filetype', '') == 'cpp':
    pat += r'::'

below this line: https://github.com/tweekmonster/deoplete-clang2/blob/ae4552b18439cfda1e4bf82a5347484c640aa870/rplugin/python3/deoplete/sources/deoplete_clang2.py#L170

alexpyzhianov commented 7 years ago
        if objc:
            pat += r'|[:@\[]|(?:\S\s+)'
        elif context.get('filetype', '') == 'cpp':
            pat += r'::'

Like this? Nope, nothing changed

tweekmonster commented 7 years ago

Sorry, the pattern is wrong. It should be pat += r'|::'

alexpyzhianov commented 7 years ago

Wow! It works now! Thanks a lot!

tweekmonster commented 7 years ago

Great! I'll fix this shortly.