Closed linuzlover closed 5 years ago
What kind of activity do you see in the *ycmd-server*
buffer when you get completions on only a few characters? How does it differ (if at all) from when you're getting the expected results?
Here is the output in both cases.
First case (completion after "->" symbol)
2018-10-10 12:56:57,866 - DEBUG - No global extra conf, not calling method YcmCorePreload
serving on http://localhost:44079
2018-10-10 12:56:57,916 - INFO - Received event notification
2018-10-10 12:56:57,917 - DEBUG - Event name: BufferVisit
2018-10-10 12:56:57,956 - INFO - Received event notification
2018-10-10 12:56:57,956 - DEBUG - Event name: FileReadyToParse
2018-10-10 12:56:57,956 - INFO - Adding buffer identifiers for file: /home/attilio/projects/***/src/EnhancedTracker.cpp
Traceback (most recent call last):
File "/home/attilio/Workspace/ycmd/third_party/bottle/bottle.py", line 862, in _handle
return route.call(**args)
File "/home/attilio/Workspace/ycmd/third_party/bottle/bottle.py", line 1740, in wrapper
rv = callback(*a, **ka)
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/watchdog_plugin.py", line 107, in wrapper
return callback( *args, **kwargs )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/hmac_plugin.py", line 70, in wrapper
body = callback( *args, **kwargs )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/handlers.py", line 70, in EventNotification
event_handler )( request_data )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 381, in OnFileReadyToParse
flags, filename = self._FlagsForRequest( request_data )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 480, in _FlagsForRequest
return self._flags.FlagsForFile( filename, client_data = client_data )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 131, in FlagsForFile
results = self._GetFlagsFromExtraConfOrDatabase( filename, client_data )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 170, in _GetFlagsFromExtraConfOrDatabase
module = extra_conf_store.ModuleForSourceFile( filename )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/extra_conf_store.py", line 66, in ModuleForSourceFile
return Load( ModuleFileForSourceFile( filename ) )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/extra_conf_store.py", line 77, in ModuleFileForSourceFile
if Load( module_file ):
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/extra_conf_store.py", line 163, in Load
if not force and not _ShouldLoad( module_file, is_global ):
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/extra_conf_store.py", line 146, in _ShouldLoad
raise UnknownExtraConf( module_file )
ycmd.responses.UnknownExtraConf: Found /home/attilio/projects/***/.ycm_extra_conf.py. Load?
(Question can be turned off with options, see YCM docs)
2018-10-10 12:57:03,806 - INFO - Received extra conf load request
2018-10-10 12:57:03,857 - INFO - Received event notification
2018-10-10 12:57:03,858 - DEBUG - Event name: FileReadyToParse
2018-10-10 12:57:03,858 - INFO - Adding buffer identifiers for file: /home/attilio/projects/***/src/EnhancedTracker.cpp
2018-10-10 12:57:08,113 - INFO - Received filetype completion available request
2018-10-10 12:57:08,180 - INFO - Received defined subcommands request
2018-10-10 12:57:08,218 - INFO - Received command request
2018-10-10 12:57:09,995 - INFO - Received command request
2018-10-10 12:57:15,818 - INFO - Received event notification
2018-10-10 12:57:15,819 - DEBUG - Event name: FileReadyToParse
2018-10-10 12:57:15,819 - INFO - Adding buffer identifiers for file: /home/attilio/projects/***/src/EnhancedTracker.cpp
2018-10-10 12:57:15,914 - INFO - Received event notification
2018-10-10 12:57:15,914 - DEBUG - Event name: FileReadyToParse
2018-10-10 12:57:15,915 - INFO - Adding buffer identifiers for file: /home/attilio/projects/***src/EnhancedTracker.cpp
2018-10-10 12:57:16,649 - INFO - Received command request
2018-10-10 12:57:19,419 - INFO - Received completion request
2018-10-10 12:57:19,420 - DEBUG - Using filetype completion: True
2018-10-10 12:57:24,660 - INFO - Received command request
Second case (right behavior), completion after ->check (method name is chechAllToolsVisible()
2018-10-10 12:56:57,866 - DEBUG - No global extra conf, not calling method YcmCorePreload
serving on http://localhost:44079
2018-10-10 12:56:57,916 - INFO - Received event notification
2018-10-10 12:56:57,917 - DEBUG - Event name: BufferVisit
2018-10-10 12:56:57,956 - INFO - Received event notification
2018-10-10 12:56:57,956 - DEBUG - Event name: FileReadyToParse
2018-10-10 12:56:57,956 - INFO - Adding buffer identifiers for file: /home/attilio/projects/***/src/EnhancedTracker.cpp
Traceback (most recent call last):
File "/home/attilio/Workspace/ycmd/third_party/bottle/bottle.py", line 862, in _handle
return route.call(**args)
File "/home/attilio/Workspace/ycmd/third_party/bottle/bottle.py", line 1740, in wrapper
rv = callback(*a, **ka)
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/watchdog_plugin.py", line 107, in wrapper
return callback( *args, **kwargs )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/hmac_plugin.py", line 70, in wrapper
body = callback( *args, **kwargs )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/handlers.py", line 70, in EventNotification
event_handler )( request_data )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 381, in OnFileReadyToParse
flags, filename = self._FlagsForRequest( request_data )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 480, in _FlagsForRequest
return self._flags.FlagsForFile( filename, client_data = client_data )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 131, in FlagsForFile
results = self._GetFlagsFromExtraConfOrDatabase( filename, client_data )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/completers/cpp/flags.py", line 170, in _GetFlagsFromExtraConfOrDatabase
module = extra_conf_store.ModuleForSourceFile( filename )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/extra_conf_store.py", line 66, in ModuleForSourceFile
return Load( ModuleFileForSourceFile( filename ) )
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/extra_conf_store.py", line 77, in ModuleFileForSourceFile
if Load( module_file ):
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/extra_conf_store.py", line 163, in Load
if not force and not _ShouldLoad( module_file, is_global ):
File "/home/attilio/Workspace/ycmd/ycmd/../ycmd/extra_conf_store.py", line 146, in _ShouldLoad
raise UnknownExtraConf( module_file )
ycmd.responses.UnknownExtraConf: Found /home/attilio/projects/***/.ycm_extra_conf.py. Load?
(Question can be turned off with options, see YCM docs)
2018-10-10 12:57:03,806 - INFO - Received extra conf load request
2018-10-10 12:57:03,857 - INFO - Received event notification
2018-10-10 12:57:03,858 - DEBUG - Event name: FileReadyToParse
2018-10-10 12:57:03,858 - INFO - Adding buffer identifiers for file: /home/attilio/projects/***/src/EnhancedTracker.cpp
2018-10-10 12:57:08,113 - INFO - Received filetype completion available request
2018-10-10 12:57:08,180 - INFO - Received defined subcommands request
2018-10-10 12:57:08,218 - INFO - Received command request
2018-10-10 12:57:09,995 - INFO - Received command request
2018-10-10 12:57:15,818 - INFO - Received event notification
2018-10-10 12:57:15,819 - DEBUG - Event name: FileReadyToParse
2018-10-10 12:57:15,819 - INFO - Adding buffer identifiers for file: /home/attilio/projects/***/src/EnhancedTracker.cpp
2018-10-10 12:57:15,914 - INFO - Received event notification
2018-10-10 12:57:15,914 - DEBUG - Event name: FileReadyToParse
2018-10-10 12:57:15,915 - INFO - Adding buffer identifiers for file: /home/attilio/projects/***/src/EnhancedTracker.cpp
2018-10-10 12:57:16,649 - INFO - Received command request
2018-10-10 12:57:19,419 - INFO - Received completion request
2018-10-10 12:57:19,420 - DEBUG - Using filetype completion: True
2018-10-10 12:57:24,660 - INFO - Received command request
2018-10-10 12:58:37,599 - INFO - Received command request
2018-10-10 12:58:38,452 - INFO - Received command request
2018-10-10 12:58:38,982 - INFO - Received command request
2018-10-10 12:58:40,609 - INFO - Received completion request
2018-10-10 12:58:40,610 - DEBUG - Using filetype completion: True
2018-10-10 12:58:40,627 - INFO - Received completion request
2018-10-10 12:58:40,628 - DEBUG - Using filetype completion: True
2018-10-10 12:58:40,672 - INFO - Received completion request
2018-10-10 12:58:40,672 - DEBUG - Using filetype completion: True
2018-10-10 12:58:40,685 - INFO - Received command request
2018-10-10 12:58:40,837 - INFO - Received completion request
2018-10-10 12:58:40,838 - DEBUG - Using filetype completion: True
2018-10-10 12:58:41,426 - INFO - Received completion request
2018-10-10 12:58:41,426 - DEBUG - Using filetype completion: True
2018-10-10 12:58:41,451 - INFO - Received command request
2018-10-10 12:58:44,309 - INFO - Received completion request
2018-10-10 12:58:44,310 - DEBUG - Using filetype completion: True
Do you need my init.el?
Thank you for your support
Do you need my init.el?
That might help, but it's hard to say. Could you post your .ycm_extra_conf.py
as well?
My guess is that ycmd.el
is behaving correctly and is just showing you what ycmd is returning. There's likely just some misconfiguration of ycmd.el, company, or ycmd itself which is leading the confusion.
Here is the .ycm_extra_conf.py created by YCM Generator:
# Generated by YCM Generator at 2018-10-08 10:49:59.226131
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
import os
import ycm_core
flags = [
'-x',
'c',
'-DCAPICOMMON_EXPORTS',
'-DCMAKE',
'-DHAVE_GETADDRINFO_A',
'-DVERSION="1.5.0"',
'-DWITH_BRIDGE',
'-DWITH_BROKER',
'-DWITH_EC',
'-DWITH_MEMORY_TRACKING',
'-DWITH_PERSISTENCE',
'-DWITH_SOCKS',
'-DWITH_SYS_TREE',
'-DWITH_THREADING',
'-DWITH_TLS',
'-DWITH_TLS_PSK',
'-DWITH_UUID',
'-Dlibmosquitto_EXPORTS',
'-I/home/attilio/projects/***/3pp/CAPIcommon/include',
'-I/home/attilio/projects/***/3pp/CAPIcommon/src/include',
'-I/home/attilio/projects/***/3pp/eigen-git-mirror',
'-I/home/attilio/projects/***/3pp/mosquitto',
'-I/home/attilio/projects/***/3pp/mosquitto/lib',
'-I/home/attilio/projects/***/3pp/mosquitto/lib/cpp',
'-I/home/attilio/projects/***/3pp/mosquitto/src',
'-I/home/attilio/projects/***/include',
'-Wall',
'-Wextra',
]
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# You can get CMake to generate this file for you by adding:
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
# to your CMakeLists.txt file.
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''
if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
SOURCE_EXTENSIONS = [ '.C', '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break
if new_flag:
new_flags.append( new_flag )
return new_flags
def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.H', '.h', '.hxx', '.hpp', '.hh' ]
def GetCompilationInfoForFile( filename ):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
compilation_info = database.GetCompilationInfoForFile(
replacement_file )
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile( filename )
def FlagsForFile( filename, **kwargs ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
return {
'flags': final_flags,
'do_cache': True
}
Here, instead, you find my init.el. I apologize for its ugliness, it is just a draft :$
;;; package --- Summary:
;;; Commentary:
(require 'package)
;;; Code:
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(add-to-list 'load-path "~/.emacs.d/custom")
(require 'setup-general)
(if (version< emacs-version "24.4")
(require 'setup-ivy-counsel)
(require 'setup-helm)
(require 'setup-helm-gtags))
(require 'setup-cedet)
(require 'setup-editing)
;;Activate minibuffer autoresize
(helm-autoresize-mode t)
;;Activate M-x substitute
(global-set-key (kbd "M-x") 'helm-M-x)
;;Activate man
(add-to-list 'helm-sources-using-default-as-input 'helm-source-man-pages)
;;Find occurrences in this file
(global-set-key (kbd "C-c h o") 'helm-occur)
; Snippets
(use-package yasnippet
:ensure t
:diminish yas-minor-mode
:init (yas-global-mode t))
(require 'validate)
;; Code-comprehension server
(use-package ycmd
:ensure t
:init (add-hook 'c++-mode-hook #'ycmd-mode)
:config
(set-variable 'ycmd-server-command '("python3" "/home/attilio/Workspace/ycmd/ycmd"))
)
(use-package company-ycmd
:ensure t
:init (company-ycmd-setup)
)
(require 'ycmd-eldoc)
(add-hook 'ycmd-mode-hook 'ycmd-eldoc-setup)
(setq-local company-backends (remove 'company-semantic company-backends))
(define-key c-mode-map [(tab)] 'company-complete)
(define-key c++-mode-map [(tab)] 'company-complete)
;;Use Meta+arrow to switch windows
(windmove-default-keybindings 'meta)
;;Indent when a newline is pressed
(global-set-key (kbd "RET") 'newline-and-indent) ; automatically indent when press RET
;; activate whitespace-mode to view all whitespace characters
(global-set-key (kbd "C-c w") 'whitespace-mode)
;; show unncessary whitespace that can mess up your diff
(add-hook 'prog-mode-hook (lambda () (interactive) (setq show-trailing-whitespace 1)))
;; use space to indent by default
(setq-default indent-tabs-mode nil)
;; set appearance of a tab that is represented by 4 spaces
(setq-default tab-width 4)
;; Package: smartparens
(require 'smartparens-config)
(show-smartparens-global-mode +1)
(smartparens-global-mode 1)
;; when you press RET, the curly braces automatically
;; add another newline
(sp-with-modes '(c-mode c++-mode)
(sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET")))
(sp-local-pair "/*" "*/" :post-handlers '((" | " "SPC")
("* ||\n[i]" "RET"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; undo tree mode ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;turn on everywhere
(global-undo-tree-mode 1)
;; make ctrl-z undo
(global-set-key (kbd "C-z") 'undo)
;; make ctrl-Z redo
(defalias 'redo 'undo-tree-redo)
(global-set-key (kbd "C-S-z") 'redo)
;; function-args
;; (require 'function-args)
;; (fa-config-default)
;; (define-key c-mode-map [(tab)] 'company-complete)
;; (define-key c++-mode-map [(tab)] 'company-complete)
(setq c-default-style "ellemtel"
c-basic-offset 4)
;;reformat buffer using F12
(defun indent-buffer ()
(interactive)
(save-excursion
(indent-region (point-min) (point-max) nil)))
(global-set-key [f12] 'indent-buffer)
(require 'helm-flycheck) ;; Not necessary if using ELPA package
; Force flycheck to always use c++11 support. We use
;; the clang language backend so this is set to clang
(add-hook 'c++-mode-hook
(lambda () (setq flycheck-clang-language-standard "c++11")))
;; Turn flycheck on everywhere
(global-flycheck-mode)
;; Package: yasnippet
;;(require 'yasnippet)
;;(yas-global-mode 1)
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
(load-theme 'gruvbox-dark-soft t)
(require 'highlight-doxygen)
(highlight-doxygen-global-mode 1)
(add-to-list 'load-path "~/.emacs.d/doxymacs/lisp/")
(load "doxymacs")
(require 'doxymacs)
(doxymacs-mode 1)
(require 'srefactor)
(define-key c-mode-map (kbd "M-RET") 'srefactor-refactor-at-point)
(define-key c++-mode-map (kbd "M-RET") 'srefactor-refactor-at-point)
(set-face-attribute 'default nil :family "Anonymous Pro" :height 180)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
(quote
(validate flycheck-ycmd company-ycmd highlight-doxygen srefactor gruvbox-theme distinguished-theme zenburn-theme nyan-mode zygospore yasnippet-snippets volatile-highlights use-package undo-tree smartparens iedit helm-swoop helm-projectile helm-gtags helm-flycheck dtrt-indent dracula-theme company-irony-c-headers company-irony company-c-headers comment-dwim-2 clean-aindent-mode anzu)))
'(safe-local-variable-values
(quote
((eval setq flycheck-clang-include-path
(list
(expand-file-name "/home/attilio/projects/***/include/.")
(expand-file-name "/home/attilio/projects/***/3pp/CAPIcommon/include/.")
(expand-file-name "/home/attilio/projects/***/3pp/mosquitto/lib/.")
(expand-file-name "/home/attilio/projects/***/3pp/mosquitto/lib/cpp/.")
(expand-file-name "/home/attilio/projects/***/3pp/eigen-git-mirror/.")))))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(nyan-mode)
(provide 'init)
;;; init.el ends here
Again, thank you for your time.
AP
Do you need my init.el?
That might help, but it's hard to say. Could you post your
.ycm_extra_conf.py
as well?My guess is that
ycmd.el
is behaving correctly and is just showing you what ycmd is returning. There's likely just some misconfiguration of ycmd.el, company, or ycmd itself which is leading the confusion.
@abingham Your comment inspired me and I modified the .ycm_extra_conf.py file adding the compilation_database_folder variable. Now, it behaves as expected. I will test it and I will close the issue.
TY!
AP
Excellent! I'm glad you got that sorted out.
Hi,
I am using company-ycmd 20180520.1053 with ycmd server commit 522bf1c83e40978f36f5704bf31b70b2d835fa99. I noticed a strange behavior on completion when I try to complete a member function using just a few characters. In particular:
However, if i try to complete after inserting exactly 5 chars, I get the right member functions:
Is there any way to obtain the right candidates using less than 5 chars?
Thanks
AP
Edit:
I forgot to attach the init.el portion where company-ycmd is initialized:
It is based on https://onze.io/emacs/c++/2017/03/16/emacs-cpp.html