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

[Feature request]: Display current context, e.g. add GetType or some sort of GetBreadcrumbs support for LSP completer #4096

Open
12 tasks done
whoisdylan opened this issue Dec 13, 2022 · 3 comments

Comments

@whoisdylan
Copy link

whoisdylan commented Dec 13, 2022

Issue Prelude

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

  • I have read and understood YCM's CONTRIBUTING document.
  • I have read and understood YCM's CODE_OF_CONDUCT document.
  • I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • 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.
    )
  • If filing a bug report, I have included the output of vim --version.
  • If filing a bug report, I have included the output of :YcmDebugInfo.
  • If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • If filing a bug report, I have included a minimal test case that reproduces
    my issue, using vim -Nu /path/to/YCM/vimrc_ycm_minimal, including what I
    expected to happen and what actually happened.
  • If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • 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.
  • 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?

When running :YcmCompleter GetParent within a cpp file, I am seeing "ValueError: Supported commands are:..." which doesn't include GetParent. According to the readme, GetParent should be supported for cpp files though. GoToDeclaration and the rest are working

Include steps to reproduce here.

  1. Open a cpp file with eg vim -Nu /path/to/YCM/vimrc_ycm_minimal main.cpp (I am using bazel + hedronvision compile commands generator to get a compile_commands.json, but the error will be present without any compile flags)
  2. Run :YcmCompleter GetParent
  3. Behold

Diagnostic data

Output of vim --version

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Oct  6 2022 10:33:05)
Included patches: 1-676
Compiled by me
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
+balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
+browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     -perl              +title
+channel           +ipv6              +persistent_undo   +toolbar
+cindent           +job               +popupwin          +user_commands
+clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           +python/dyn        +viminfo
+cmdline_info      +libcall           +python3/dyn       +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          -ruby              +wildignore
+cursorbind        -lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con_gui    +mksession         +smartindent       +writebackup
+diff              +modify_fname      -sodium            +X11
+digraphs          +mouse             -sound             -xfontset
+dnd               +mouseshape        +spell             +xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        -mouse_gpm         +statusline        +xsmp_interact
+eval              -mouse_jsbterm     -sun_workshop      +xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary        
-farsi             -mouse_sysmouse    -tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/data2/me/.local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lrt -ldl 

Output of YcmDebugInfo

-- Resolve completions: Up front
-- Client logfile: /tmp/ycm_qx58cxjy.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.8.0
-- Server has Clang support compiled in: False
-- Clang version: None
-- Extra configuration file found and loaded
-- Extra configuration path: /data2/me/gits/project/.ycm_extra_conf.py
-- C-family completer debug information:
--   Clangd running
--   Clangd process ID: 5129
--   Clangd executable: ['~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/clangd/output/bin/clangd', '-header-insertion-decorators=0', '-resource-dir=~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/clang/lib/clang/15.0.1', '-limit-results=500']
--   Clangd logfiles:
--     /tmp/clangd_stderre7mxo6hr.log
--   Clangd Server State: Initialized
--   Clangd Project Directory: /data2/me/gits/project
--   Clangd Settings: {}
--   Clangd Compilation Command: False
-- Server running at: http://127.0.0.1:57249
-- Server process ID: 5115
-- Server logfiles:
--   /tmp/ycmd_57249_stdout_2c5trxz_.log
--   /tmp/ycmd_57249_stderr_9t1ciev2.log
-- Semantic highlighting supported: True
-- Virtual text supported: True
-- Popup windows supported: True

Output of YcmDiags

No warnings or errors detected.

Output of git rev-parse HEAD in YouCompleteMe installation directory

508b8c64bfbc2ad3106ae67b7828936035b3095e

Contents of YCM, ycmd and completion engine logfiles

Reproduce the issue with vim -Nu /path/to/YCM/vimrc_ycm_minimal, which
enabled debug logging and other useful diagnostics. Include a link to a
gist containing all of the log files listed by :YcmToggleLogs.
logs contain a lot of sensitive info, pls advise if needed

from ycmd stderr log:

2022-12-12 16:28:21,693 - INFO - Found executeCommandProvider support for command ExecuteCommand in cfamily
2022-12-12 16:28:21,693 - INFO - Found codeActionProvider support for command FixIt in cfamily
2022-12-12 16:28:21,693 - INFO - Found definitionProvider support for command GoToDefinition in cfamily
2022-12-12 16:28:21,693 - INFO - Found declarationProvider support for command GoToDeclaration in cfamily
2022-12-12 16:28:21,693 - INFO - Found ('definitionProvider', 'declarationProvider') support for command GoTo in cfamily
2022-12-12 16:28:21,693 - INFO - Found typeDefinitionProvider support for command GoToType in cfamily
2022-12-12 16:28:21,693 - INFO - Found implementationProvider support for command GoToImplementation in cfamily
2022-12-12 16:28:21,694 - INFO - Found referencesProvider support for command GoToReferences in cfamily
2022-12-12 16:28:21,694 - INFO - Found renameProvider support for command RefactorRename in cfamily
2022-12-12 16:28:21,694 - INFO - Found documentFormattingProvider support for command Format in cfamily
2022-12-12 16:28:21,694 - INFO - Found workspaceSymbolProvider support for command GoToSymbol in cfamily
2022-12-12 16:28:21,694 - INFO - Found documentSymbolProvider support for command GoToDocumentOutline in cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting StopServer for cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting RestartServer for cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting GetDoc for cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting GetType for cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting GoToCallees for cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting GoToCallers for cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting GetTypeImprecise for cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting GoToImprecise for cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting GoToInclude for cfamily
2022-12-12 16:28:21,694 - INFO - Always supporting GetDocImprecise for cfamily
2022-12-12 16:28:21,694 - INFO - Found executeCommandProvider support for command ExecuteCommand in cfamily
2022-12-12 16:28:21,694 - INFO - Found codeActionProvider support for command FixIt in cfamily
2022-12-12 16:28:21,694 - INFO - Found definitionProvider support for command GoToDefinition in cfamily
2022-12-12 16:28:21,694 - INFO - Found declarationProvider support for command GoToDeclaration in cfamily
2022-12-12 16:28:21,695 - INFO - Found ('definitionProvider', 'declarationProvider') support for command GoTo in cfamily
2022-12-12 16:28:21,695 - INFO - Found typeDefinitionProvider support for command GoToType in cfamily
2022-12-12 16:28:21,695 - INFO - Found implementationProvider support for command GoToImplementation in cfamily
2022-12-12 16:28:21,695 - INFO - Found referencesProvider support for command GoToReferences in cfamily
2022-12-12 16:28:21,695 - INFO - Found renameProvider support for command RefactorRename in cfamily
2022-12-12 16:28:21,695 - INFO - Found documentFormattingProvider support for command Format in cfamily
2022-12-12 16:28:21,695 - INFO - Found workspaceSymbolProvider support for command GoToSymbol in cfamily
2022-12-12 16:28:21,695 - INFO - Found documentSymbolProvider support for command GoToDocumentOutline in cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting StopServer for cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting RestartServer for cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting GetDoc for cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting GetType for cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting GoToCallees for cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting GoToCallers for cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting GetTypeImprecise for cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting GoToImprecise for cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting GoToInclude for cfamily
2022-12-12 16:28:21,695 - INFO - Always supporting GetDocImprecise for cfamily
Traceback (most recent call last):
  File "~/vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/completers/completer.py", line 477, in OnUserCommand
    command = command_map[ arguments[ 0 ] ]
KeyError: 'GetParent'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "~/vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 876, in _handle
    return route.call(**args)
  File "~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1756, in wrapper
    rv = callback(*a, **ka)
  File "~/vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/watchdog_plugin.py", line 97, in wrapper
    return callback( *args, **kwargs )
  File "~/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/hmac_plugin.py", line 62, in wrapper
    body = callback( *args, **kwargs )
  File "~/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/handlers.py", line 93, in RunCompleterCommand
    return _JsonResponse( completer.OnUserCommand(
  File "~/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/completers/completer.py", line 479, in OnUserCommand
    raise ValueError( self.UserCommandsHelpMessage() )
ValueError: Supported commands are:
ExecuteCommand
FixIt
Format
GetDoc
GetDocImprecise
GetType
GetTypeImprecise
GoTo
GoToCallees
GoToCallers
GoToDeclaration
GoToDefinition
GoToDocumentOutline
GoToImplementation
GoToImprecise
GoToInclude
GoToReferences
GoToSymbol
GoToType
RefactorRename
RestartServer
See the docs for information on what they do.

OS version, distribution, etc.

Include system information here.

Ubuntu server 18.04

Output of build/install commands

Include link to a gist containing the invocation and entire output of
install.py if reporting an installation issue.

Thank you for taking a look 😃

@puremourning
Copy link
Member

GetParent was supported in the legacy libclang completer but cannot be provided by clangd. It’s essentially deprecated at this point.

@whoisdylan
Copy link
Author

Roger, thank you. I ask bc I'm interested in adding a way to get "breadcrumbs" of the current function/method I'm in a la visual studio and others (see https://i.stack.imgur.com/wu4kP.png) using the LSP and GetParent seemed like a good entry point.

@puremourning do you have any thoughts on how one could go about adding this feature? My vimscript fu is weak, but I was thinking of using YCM commands to update the status line, or if needed a separate plugin that talks LSP and maybe plugins into airline/lightline. I've seen some ppl implement this (eg vista + coc) but not with YCM integrated yet sadly

@puremourning
Copy link
Member

I think it is possible to do using the document symbols data when supporting the "hierarchical" data response. the server provides a whole hierarchy and you can sort of walk that using the current cursor position.

ycmd doesn't currently support that. Using it to implement a GetParent subcommand might be simple, but I suspect that it would be better to implement some sort of "GetBreadcrumbs" request. In a simple form it could just return the symbol names, but it could also return say a list of positions you can jump to. That would be a fair amount more work of course, though it might be worth it.

I'll re-open this as a feat req.

@puremourning puremourning reopened this Dec 13, 2022
@puremourning puremourning changed the title GetParent not supported in cpp file [Feature request]: Display current context, e.g. add GetType or some sort of GetBreadcrumbs support for LSP completes Dec 13, 2022
@puremourning puremourning changed the title [Feature request]: Display current context, e.g. add GetType or some sort of GetBreadcrumbs support for LSP completes [Feature request]: Display current context, e.g. add GetType or some sort of GetBreadcrumbs support for LSP completer Dec 13, 2022
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