Skip to content

clangd completion does not work #72

@kwon-young

Description

@kwon-young

Hello,
Following this thread: https://www.reddit.com/r/neovim/comments/6j12mr/getting_clangd_llvms_lsp_implementation_for_c_to/
I decided to try and make the clangd language server for c++ work.
However, I obtained the same results where the linting of errors works but the completion using deoplete and python3 does not.
Following the advice of ShougoMatsu, i'm creating this issue to provide more detailed information.

  • OS: manjaro/Linux
  • neovim version: v0.2.0
  • Plugin version (git SHA): 223857f
  • Minimal vimrc:
call plug#begin('~/.vim/plugged')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'autozimu/LanguageClient-neovim', { 'do': ':UpdateRemotePlugins' }
call plug#end()
let g:deoplete#enable_at_startup = 1
set hidden
let g:LanguageClient_serverCommands = {
    \ 'cpp': ['clangd']
    \ }
let g:LanguageClient_autoStart = 1
let g:LanguageClient_trace = 'verbose'
  • Content of :CheckHealth:

health#deoplete#check
========================================================================
## deoplete.nvim
  - SUCCESS: has("nvim") was successful
  - SUCCESS: has("python3") was successful
  - INFO: If you're still having problems, try the following commands:
    $ export NVIM_PYTHON_LOG_FILE=/tmp/log
    $ export NVIM_PYTHON_LOG_LEVEL=DEBUG
    $ nvim
    $ cat /tmp/log_{PID}
    and then create an issue on github

health#nvim#check
========================================================================
## Configuration
  - SUCCESS: no issues found

## Performance
  - SUCCESS: Build type: Release

## Remote Plugins
  - SUCCESS: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~

health#provider#check
========================================================================
## Clipboard (optional)
  - SUCCESS: Clipboard tool found: xclip

## Python 2 provider (optional)
  - WARNING: No Python interpreter was found with the neovim module.  Using the first available for diagnostics.
  - WARNING: provider/pythonx: Could not load Python 2:
    /usr/bin/python2 does not have the "neovim" module. :help |provider-python|
    /usr/bin/python2.7 does not have the "neovim" module. :help |provider-python|
    python2.6 not found in search path or not executable.
    /usr/bin/python is Python 3.6 and cannot provide Python 2.
  - ERROR: Python provider error
    - SUGGESTIONS:
      - provider/pythonx: Could not load Python 2:
          /usr/bin/python2 does not have the "neovim" module. :help |provider-python|
          /usr/bin/python2.7 does not have the "neovim" module. :help |provider-python|
          python2.6 not found in search path or not executable.
          /usr/bin/python is Python 3.6 and cannot provide Python 2.
  - INFO: Executable: Not found

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Executable: /usr/bin/python3
  - INFO: Python3 version: 3.6.1
  - INFO: python3-neovim version: 0.1.13
  - SUCCESS: Latest python3-neovim is installed: 0.1.13

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
  - WARNING: Missing "neovim" gem.
    - SUGGESTIONS:
      - Run in shell: gem install neovim
      - Is the gem bin directory in $PATH? Check `gem environment`.
      - If you are using rvm/rbenv/chruby, try "rehashing".
  • Content of ~/.local/share/nvim/rplugin.vim:
" python3 plugins
call remote#host#RegisterPlugin('python3', '/home/vim/.vim/plugged/LanguageClient-neovim/rplugin/python3/LanguageClient', [
      \ {'sync': v:true, 'name': 'LanguageClient_alive', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_completionItem/resolve', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_completionManager_refresh', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_exit', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_FZFSinkTextDocumentDocumentSymbol', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_FZFSinkTextDocumentReferences', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_FZFSinkWorkspaceSymbol', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'BufReadPost', 'type': 'autocmd', 'opts': {'pattern': '*'}},
      \ {'sync': v:false, 'name': 'CursorMoved', 'type': 'autocmd', 'opts': {'pattern': '*', 'eval': 'line(''.'')'}},
      \ {'sync': v:false, 'name': 'VimEnter', 'type': 'autocmd', 'opts': {'pattern': '*'}},
      \ {'sync': v:false, 'name': 'LanguageClient_initialize', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_registerServerCommands', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_setLoggingLevel', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClientStart', 'type': 'command', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClientStop', 'type': 'command', 'opts': {}},
      \ {'sync': v:false, 'name': 'TextChanged', 'type': 'autocmd', 'opts': {'pattern': '*'}},
      \ {'sync': v:false, 'name': 'TextChangedI', 'type': 'autocmd', 'opts': {'pattern': '*'}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_completion', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_completionOmnifunc', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_definition', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_didClose', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'BufWritePost', 'type': 'autocmd', 'opts': {'pattern': '*'}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_documentSymbol', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_formatting', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_hover', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_references', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_rename', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_signatureHelp', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_workspace_symbol', 'type': 'function', 'opts': {}},
     \ ])
call remote#host#RegisterPlugin('python3', '/home/vim/.vim/plugged/deoplete.nvim/rplugin/python3/deoplete', [
      \ {'sync': v:true, 'name': '_deoplete', 'type': 'function', 'opts': {}},
     \ ])


" ruby plugins


" python plugins
  • Run :call LanguageClient_setLoggingLevel('DEBUG') and then
    :LanguageClientStart, reproduce the bug (tried to do omni-completion), attach content of
    /tmp/LanguageClient.log:
Args: /home/vim/prog/llvm-build/bin/clangd -debug -stats 
17:45:46 WARNING  Unknown project type. Fallback to use dir as project root.
Content-Length: 168

{"jsonrpc": "2.0", "method": "initialize", "params": {"processId": 1763, "rootPath": "/tmp", "rootUri": "file:///tmp", "capabilities": {}, "trace": "verbose"}, "id": 0}<-- {"jsonrpc": "2.0", "method": "initialize", "params": {"processId": 1763, "rootPath": "/tmp", "rootUri": "file:///tmp", "capabilities": {}, "trace": "verbose"}, "id": 0}
Notification ignored.
17:46:01 INFO     Begin textDocument/completion
17:46:01 INFO     textDocument/didChange
17:46:01 INFO     textDocument/didOpen
17:46:01 DEBUG     => {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"uri": "file:///tmp/main.cpp", "languageId": "cpp", "version": 1, "text": "class Foo {\n  public:\n    int bar;\n};\n\nint main(int argc, char* argv[]) {\n  Foo foo;\n  foo.\n  return 0;\n}\n"}}}
Content-Length: 276

{"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"uri": "file:///tmp/main.cpp", "languageId": "cpp", "version": 1, "text": "class Foo {\n  public:\n    int bar;\n};\n\nint main(int argc, char* argv[]) {\n  Foo foo;\n  foo.\n  return 0;\n}\n"}}}<-- {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"uri": "file:///tmp/main.cpp", "languageId": "cpp", "version": 1, "text": "class Foo {\n  public:\n    int bar;\n};\n\nint main(int argc, char* argv[]) {\n  Foo foo;\n  foo.\n  return 0;\n}\n"}}}
17:46:01 DEBUG     => {"jsonrpc": "2.0", "method": "textDocument/completion", "params": {"textDocument": {"uri": "file:///tmp/main.cpp"}, "position": {"line": 7, "character": 6}}, "id": 1}
Content-Length: 166

{"jsonrpc": "2.0", "method": "textDocument/completion", "params": {"textDocument": {"uri": "file:///tmp/main.cpp"}, "position": {"line": 7, "character": 6}}, "id": 1}<-- {"jsonrpc": "2.0", "method": "textDocument/completion", "params": {"textDocument": {"uri": "file:///tmp/main.cpp"}, "position": {"line": 7, "character": 6}}, "id": 1}
Notification ignored.
--> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///tmp/main.cpp","diagnostics":[{"range":{"start": {"line": 8, "character": 3}, "end": {"line": 8, "character": 3}},"severity":1,"message":"expected unqualified-id"}]}}
Content-Length: 250

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///tmp/main.cpp","diagnostics":[{"range":{"start": {"line": 8, "character": 3}, "end": {"line": 8, "character": 3}},"severity":1,"message":"expected unqualified-id"}]}}17:46:01 DEBUG     <= {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///tmp/main.cpp","diagnostics":[{"range":{"start": {"line": 8, "character": 3}, "end": {"line": 8, "character": 3}},"severity":1,"message":"expected unqualified-id"}]}}
17:46:12 INFO     Begin textDocument/completion
17:46:13 INFO     textDocument/didChange
17:46:13 DEBUG     => {"jsonrpc": "2.0", "method": "textDocument/didChange", "params": {"textDocument": {"uri": "file:///tmp/main.cpp", "version": 2}, "contentChanges": [{"text": "class Foo {\n  public:\n    int bar;\n};\n\nint main(int argc, char* argv[]) {\n  Foo foo;\n  foo.1\n  return 0;\n}\n"}]}}
Content-Length: 280

{"jsonrpc": "2.0", "method": "textDocument/didChange", "params": {"textDocument": {"uri": "file:///tmp/main.cpp", "version": 2}, "contentChanges": [{"text": "class Foo {\n  public:\n    int bar;\n};\n\nint main(int argc, char* argv[]) {\n  Foo foo;\n  foo.1\n  return 0;\n}\n"}]}}<-- {"jsonrpc": "2.0", "method": "textDocument/didChange", "params": {"textDocument": {"uri": "file:///tmp/main.cpp", "version": 2}, "contentChanges": [{"text": "class Foo {\n  public:\n    int bar;\n};\n\nint main(int argc, char* argv[]) {\n  Foo foo;\n  foo.1\n  return 0;\n}\n"}]}}
17:46:13 INFO     textDocument/didChange
17:46:13 DEBUG     => {"jsonrpc": "2.0", "method": "textDocument/completion", "params": {"textDocument": {"uri": "file:///tmp/main.cpp"}, "position": {"line": 7, "character": 7}}, "id": 2}
Content-Length: 166

{"jsonrpc": "2.0", "method": "textDocument/completion", "params": {"textDocument": {"uri": "file:///tmp/main.cpp"}, "position": {"line": 7, "character": 7}}, "id": 2}<-- {"jsonrpc": "2.0", "method": "textDocument/completion", "params": {"textDocument": {"uri": "file:///tmp/main.cpp"}, "position": {"line": 7, "character": 7}}, "id": 2}
Notification ignored.
--> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///tmp/main.cpp","diagnostics":[{"range":{"start": {"line": 7, "character": 6}, "end": {"line": 7, "character": 6}},"severity":1,"message":"expected ';' after expression"},{"range":{"start": {"line": 7, "character": 8}, "end": {"line": 7, "character": 8}},"severity":1,"message":"expected ';' after expression"},{"range":{"start": {"line": 7, "character": 3}, "end": {"line": 7, "character": 3}},"severity":2,"message":"expression result unused"},{"range":{"start": {"line": 7, "character": 6}, "end": {"line": 7, "character": 6}},"severity":2,"message":"expression result unused"}]}}
Content-Length: 666

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///tmp/main.cpp","diagnostics":[{"range":{"start": {"line": 7, "character": 6}, "end": {"line": 7, "character": 6}},"severity":1,"message":"expected ';' after expression"},{"range":{"start": {"line": 7, "character": 8}, "end": {"line": 7, "character": 8}},"severity":1,"message":"expected ';' after expression"},{"range":{"start": {"line": 7, "character": 3}, "end": {"line": 7, "character": 3}},"severity":2,"message":"expression result unused"},{"range":{"start": {"line": 7, "character": 6}, "end": {"line": 7, "character": 6}},"severity":2,"message":"expression result unused"}]}}17:46:13 DEBUG     <= {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///tmp/main.cpp","diagnostics":[{"range":{"start": {"line": 7, "character": 6}, "end": {"line": 7, "character": 6}},"severity":1,"message":"expected ';' after expression"},{"range":{"start": {"line": 7, "character": 8}, "end": {"line": 7, "character": 8}},"severity":1,"message":"expected ';' after expression"},{"range":{"start": {"line": 7, "character": 3}, "end": {"line": 7, "character": 3}},"severity":2,"message":"expression result unused"},{"range":{"start": {"line": 7, "character": 6}, "end": {"line": 7, "character": 6}},"severity":2,"message":"expression result unused"}]}}
  • minimal c++ code to do completion on line 7:
class Foo {
  public:
    int bar;
};

int main(int argc, char* argv[]) {
  Foo foo;
  foo.
  return 0;
}

I'll be happy to provide more information any time.
I've also tried the clangd language server using the visual studio code client and completion is working as expected.
I've also tried the ruby language server completion in neovim using this plugin and deoplete and it's working as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions