Youcompleteme: C++ Semantic Compleation not working where as other languages work

Created on 9 Feb 2018  路  19Comments  路  Source: ycm-core/YouCompleteMe

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:

  • [ x] I have read and understood YCM's CONTRIBUTING document.
  • [ x] I have read and understood YCM's CODE_OF_CONDUCT document.
  • [x ] I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • [ x] I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. (Example Google
    search.
    )
  • [ x] If filing a bug report, I have included the output of vim --version.
  • [ x] If filing a bug report, I have included the output of :YcmDebugInfo.
  • [ x] If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • [ x] If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • [ x] If filing a bug report, I have included a minimal test case that reproduces
    my issue, including what I expected to happen and what actually happened.
  • [ x] If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • [x ] I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt _gift_ of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • [ x] I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

Provide a clear description of the problem, including the following key
questions:

  • What did you do?
    I used ./install.py --all

    Include steps to reproduce here.
    used on a bunch of c++ files tried using Ctrl+Space I got no completion after std
    I've also tried other languages
    Include description of a minimal test case, including any actual code required
    to reproduce the issue.

  • What did you expect to happen?
    have std : : produce a completion window

    Include description of the expected behaviour.
    have a window that gives me choices of code to complete

  • What actually happened?
    it depends on the language in c++ nothing other langauges that just uses . as a trigger it works fine
    > Include description of the observed behaviour, including actual output,
    > screenshots, etc.

Diagnostic data

Output of vim --version

Place the output here, or a link to a gist.

Output of YcmDebugInfo

Place the output here, or a link to a gist.

Contents of YCM, ycmd and completion engine logfiles

Include link here to a gist containing the entire logfiles for ycm, ycmd
and any completer logfiles listed by :YcmToggleLogs.

OS version, distribution, etc.

Include system information here.

Output of build/install commands

Include link to a gist containing the invocation and entire output of
install.py if reporting an installation issue.
Log1:
17 self._response = self.PostDataToHandler( request_data, 'debug_info' )
18 File "/home/ben/.vim/bundle/youcompleteme/autoload/../python/ycm/client/base_request.py", line 79, in PostDataToHandler
19 timeout ) )
20 File "/home/ben/.vim/bundle/youcompleteme/autoload/../python/ycm/client/base_request.py", line 192, in JsonFromFuture
21 raise MakeServerException( response.json() )
22 ycmd.responses.ServerError: IndentationError: unindent does not match any outer indentation level (.ycm_extra_conf.py, line 138)

Log2:
19 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/utils.py", line 400, in LoadPythonSource
20 return imp.load_source( name, pathname )
21 File "/home/ben/.ycm_extra_conf.py", line 138
22 return flags
23 ^
24 IndentationError: unindent does not match any outer indentation level

Log3:

serving on http://127.0.0.1:35977

Most helpful comment

What @bstaletic said. Here's a minimal working example:

# Add your flags to this list.
flags = [
    '-x',
    'c++',
]

def FlagsForFile(filename):
    return {'flags': flags}

See the docs for more info on how to write that file.

All 19 comments

You have an error in your .ycm_extra_conf.py file. The indentation is wrong at line 138. If you don't mind sharing the contents of your .ycm_extra_conf.py file, we can take a look and tell you exactly what's wrong.

For the record, the clue was:

21 File "/home/ben/.ycm_extra_conf.py", line 138
22 return flags
23 ^
24 IndentationError: unindent does not match any outer indentation level

turns out there was an empty space before the return flags that I couldn't see, let me see if it works now

turns out I fixed the error and the c++ semantic completion still isn't working i have no clue what else to do

What's the output of :YcmDebugInfo? Do you get errors when running the :YcmDiags command?

YcmDebugInfo
Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_o1qms88m.log
-- Server Python interpreter: /usr/bin/python
-- Server Python version: 2.7.12
-- Server has Clang support compiled in: True
-- Clang version: clang version 5.0.0 (tags/RELEASE_500
/final)
-- Extra configuration file found and loaded
-- Extra configuration path: /home/ben/.ycm_extra_conf.
py
-- Server running at: http://127.0.0.1:37009
-- Server process ID: 11947
-- Server logfiles:
-- /tmp/ycmd_37009_stdout_73ikv7zi.log
-- /tmp/ycmd_37009_stderr_7gsj41oi.log

YcmDiags
I get No Warning or errors detected for my cpp file

Sorry, I should've asked you to run :YcmDebugInfo while editing your C++ file. What's the output in that case?

Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_n17gi_h_.log
-- Server Python interpreter: /usr/bin/python
-- Server Python version: 2.7.12
-- Server has Clang support compiled in: True
-- Clang version: clang version 5.0.0 (tags/RELEASE_500
/final)
-- Extra configuration file found and loaded
-- Extra configuration path: /home/ben/.ycm_extra_conf.
py
-- Server running at: http://127.0.0.1:37241
-- Server process ID: 12788
-- Server logfiles:
-- /tmp/ycmd_37241_stdout_osz80lhw.log
-- /tmp/ycmd_37241_stderr_ildd56jn.log

There are still probably errors in your .ycm_extra_conf.py file. Could you attach the contents of the ycmd stderr logfile after trying to get completions?

1 2018-02-09 13:32:48,810 - DEBUG - No global extra conf, not calling method YcmCorePreload
2 2018-02-09 13:32:48,896 - INFO - Received ready request
3 2018-02-09 13:32:48,910 - INFO - Received event notification
4 2018-02-09 13:32:48,910 - DEBUG - Event name: BufferVisit
5 2018-02-09 13:32:48,917 - INFO - Received event notification
6 2018-02-09 13:32:48,917 - DEBUG - Event name: FileReadyToParse
7 2018-02-09 13:32:48,918 - INFO - Adding buffer identifiers for file: /home/ben/dev/school/cpp/homework/challanges/ch4/challenge3/MagicDates.cpp
8 Traceback (most recent call last):
9 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/third_party/bottle/bottle.py", line 862, in _handle
10 return route.call(*args)
11 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/third_party/bottle/bottle.py", line 1740, in wrapper
12 rv = callback(
a, *ka)
13 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/watchdog_plugin.py", line 108, in wrapper
14 return callback( *args, *
kwargs )
15 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/hmac_plugin.py", line 70, in wrapper
16 body = callback( args, *kwargs )
17 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/handlers.py", line 70, in EventNotification
18 event_handler )( request_data )
19 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 385, in OnFileReadyToParse
20 flags = self._FlagsForRequest( request_data )
21 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 468, in _FlagsForRequest
22 return self._flags.FlagsForFile( filename, client_data = client_data )
23 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 128, in FlagsForFile
24 client_data )
25 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 159, in _GetFlagsFromExtraConfOrDatabase
26 return _CallExtraConfFlagsForFile( module, filename, client_data )
27 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 256, in _CallExtraConfFlagsForFile
28 if inspect.getargspec( module.FlagsForFile ).keywords:
29 AttributeError: 'module' object has no attribute 'FlagsForFile'
30 2018-02-09 13:32:49,023 - INFO - Received filetype completion available request
31 2018-02-09 13:32:54,723 - INFO - Received debug info request
32 2018-02-09 13:32:54,725 - ERROR - 'module' object has no attribute 'FlagsForFile'
33 Traceback (most recent call last):
34 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/handlers.py", line 238, in DebugInfo
35 request_data ).DebugInfo( request_data )
36 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 439, in DebugInfo
37 flags = self._FlagsForRequest( request_data ) or []
38 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 468, in _FlagsForRequest
39 return self._flags.FlagsForFile( filename, client_data = client_data )
40 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 128, in FlagsForFile
41 client_data )
42 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 159, in _GetFlagsFromExtraConfOrDatabase
43 return _CallExtraConfFlagsForFile( module, filename, client_data )
44 File "/home/ben/.vim/bundle/youcompleteme/third_party/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 256, in _CallExtraConfFlagsForFile
45 if inspect.getargspec( module.FlagsForFile ).keywords:
46 AttributeError: 'module' object has no attribute 'FlagsForFile'
47 2018-02-09 13:33:02,373 - INFO - Received event notification
48 2018-02-09 13:33:02,374 - DEBUG - Event name: BufferUnload

32 2018-02-09 13:32:54,725 - ERROR - 'module' object has no attribute 'FlagsForFile'

Your .ycm_extra_conf.py doesn't have def FlagsForFile( filename ):. That's the function we call to get your flags.

What @bstaletic said. Here's a minimal working example:

# Add your flags to this list.
flags = [
    '-x',
    'c++',
]

def FlagsForFile(filename):
    return {'flags': flags}

See the docs for more info on how to write that file.

do I have to use something like make when I build my project for single files? because I just ran a config_gen and it apprently collected 0 relevent entries for C / c++ collection

No, but you have to provide some flags somehow. For simple, single file code what @micbou posted about should be sufficient.

I'm 100% sure that the issue here is with your extra conf file, and carefully reading the user guide should be enough to get you working. as such i'm closing this. if you do discover a reproducible YCM bug, then we can either re-open or open a new issue (preferred)

so somehow my vim and everything got deleted I'm now having trouble as I have a g_ycm_global_ycm_extra_conf set but everytime I open a vim file I get no extra conf detected

Never mind i'm an idiot I just realized my error

Hey, did you solve this? The README says that the .ycm_extra_conf.py file calls the Settings function. Nowhere does it stipulate the requirement for FlagsForFile function. Can you please clarify?

FlagsForFile is the historical method, now deprecated and replaced by Settings. Both are supported still, but you should use Settings per the docs. https://github.com/valloric/ycmd#user-level-customization

Was this page helpful?
0 / 5 - 0 ratings