ccls icon indicating copy to clipboard operation
ccls copied to clipboard

YCM command `GoToSymbol` report `IndexError: list index out of range`

Open ihexon opened this issue 1 year ago • 0 comments

Observed behavior

When CCLS is used as the LSP server in YCM, executing :YcmCompleter GoToSymbol prompts an IndexError: list index out of range. However, GoToDefinition/GoToDeclaration/GoToReferences/GoToImplementation/GoToType all work correctly.

Is it a compatibility issue between CCLS and the GoToSymbol command in YCM?

I have compile_commands.json in the project root directory. ccls generates an index in PROJECT_ROOT/.ccls-cache/, the size is about 14 M

I have minimal vimrc:

····
call plug#begin()
 Plug 'dracula/vim'
  Plug 'ycm-core/YouCompleteMe', { 'dir': '~/YouCompleteMe', 'do': 'git submodule update --init --recursive' }
call plug#end()

let g:ycm_language_server +=
  \ [{
  \   'name': 'ccls',
  \   'cmdline': [ 'ccls' ],
  \   'filetypes': [ 'c', 'cpp', 'cuda', 'objc', 'objcpp' ],
  \   'project_root_files': [ '.ccls-root', 'compile_commands.json' ]
  \ }]
····
  • YouCompleteMe debug information:
Printing YouCompleteMe debug information...
-- Resolve completions: Up front
-- Client logfile: /tmp/ycm_ymm238fy.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.10.12
-- Server has Clang support compiled in: False
-- Clang version: None
-- Extra configuration file found and loaded
-- Extra configuration path: /home/ihexon/.vim/ext/.ycm_extra_conf.py
-- GenericLSP completer debug information:
--   cclsCompleter running
--   cclsCompleter process ID: 817616
--   cclsCompleter executable: ['/usr/local/bin/ccls']
--   cclsCompleter logfiles:
--     /tmp/cclscompleter_stderrcqtqhpjf.log
--   cclsCompleter Server State: Initialized
--   cclsCompleter Project Directory: /home/ihexon/glibc
--   cclsCompleter Settings: {}
-- Server running at: http://127.0.0.1:45979
-- Server process ID: 817598
-- Server logfiles:
--   /tmp/ycmd_45979_stdout_d9hbinid.log
--   /tmp/ycmd_45979_stderr_ew02c6a5.log
-- Semantic highlighting supported: True
-- Virtual text supported: True
-- Popup windows supported: True

File: /tmp/ycmd_45979_stderr_ew02c6a5.log

2023-12-23 18:37:29,327 - DEBUG - in-event <InotifyEvent: src_path=b'/home/ihexon/glibc/nss/nss_module.h', wd=36, mask=IN_OPEN, cookie=0, name='nss_module.h'>
2023-12-23 18:37:29,371 - DEBUG - in-event <InotifyEvent: src_path=b'/home/ihexon/glibc/sysdeps/generic/unwind.h', wd=78, mask=IN_OPEN, cookie=0, name='unwind.h'>
Traceback (most recent call last):
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 876, in _handle
    return route.call(**args)
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1756, in wrapper
    rv = callback(*a, **ka)
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/watchdog_plugin.py", line 97, in wrapper
    return callback( *args, **kwargs )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/hmac_plugin.py", line 62, in wrapper
    body = callback( *args, **kwargs )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/handlers.py", line 93, in RunCompleterCommand
    return _JsonResponse( completer.OnUserCommand(
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/completer.py", line 481, in OnUserCommand
    return command( self, request_data, arguments[ 1: ] )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 90, in <lambda>
    lambda self, request_data, args: self.GoToSymbol( request_data, args )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 2560, in GoToSymbol
    return _SymbolInfoListToGoTo( request_data, result )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 3205, in _SymbolInfoListToGoTo
    locations = [ BuildGoToLocationFromSymbol( s ) for s in
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 3205, in <listcomp>
    locations = [ BuildGoToLocationFromSymbol( s ) for s in
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 3194, in BuildGoToLocationFromSymbol
    description = ( f'{ lsp.SYMBOL_KIND[ symbol[ "kind" ] ] }: '
IndexError: list index out of range
127.0.0.1 - - [23/Dec/2023 18:37:29] "POST /run_completer_command HTTP/1.1" 500 2105
2023-12-23 18:37:33,427 - INFO - Found executeCommandProvider support for command ExecuteCommand in ccls
2023-12-23 18:37:33,427 - INFO - Found codeActionProvider support for command FixIt in ccls

System information

  • ccls version
commit f36ecb0c0e025f3f3a5c2d28c823316e5d0c48ba (grafted, HEAD -> master, origin/master, origin/HEAD)
Author: Fangrui Song <[email protected]>
Date:   Thu Dec 14 22:07:21 2023 -0800

    Adapt llvmorg-18-init-13684-ge1e34cc2a17c: llvm/Support/Host.h

ihexon avatar Dec 23 '23 11:12 ihexon