Languageclient-neovim: how to use for python?

Created on 5 Mar 2017  Â·  16Comments  Â·  Source: autozimu/LanguageClient-neovim

I installed https://github.com/palantir/python-language-server with pip and got the executable pyls, which I added to the server commands like so:

let g:LanguageClient_serverCommands = {
    \'python' : ['/Users/alokbeniwal/Library/Python/3.6/bin/pyls',]
    \ }

I call :LanguageClientStart and get no error message, but none of the LanguageClient functions are available to call. I'm not sure what's wrong with my installation, since running that executable on the command line gives the following:

2017-03-04 23:23:24,210 UTC - INFO - pyls.language_server - Starting PythonLanguageServer IO language server

Most helpful comment

It's just:
let g:LanguageClient_serverCommands = {'python': ['pyls']}

All 16 comments

Can you share here your /tmp/LanguageClient.log file content?

I suspect there might be an error occurred on your side.

It's empty.

Hmm, that's wired.

Can you turn on the debug logging and check the log file again?

:call LanguageClient_setLoggingLevel('DEBUG')
:LanguageClientStart

I can't, because the function LanguageClient_setLoggingLevel is not available. LanguageClient is in my plugin manifest, so I don't know what's wrong.

Is the function LanguageClient_setLoggingLevel in your rplugin.vim?

Also, can you run :CheckHealth and check the output?

here's rplugin.vim. logging appears to be in it.

call remote#host#RegisterPlugin('python3', '/Users/alokbeniwal/.config/nvim/bundle/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': 'CursorMoved', '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_definition', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'LanguageClient_textDocument_didClose', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'BufReadPost', 'type': 'autocmd', 'opts': {'pattern': '*'}},
      \ {'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_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': {}},
     \ ])

CheckHealth shows no issues.

I cannot comprehend you can run LanguageClientStart but not LanguageClient_setLoggingLevel.

You can edit the logging level manually at https://github.com/autozimu/LanguageClient-neovim/blob/master/rplugin/python3/LanguageClient/logger.py#L10

And if it still doesn't work, I would recommend try with a minimal vimrc and report back details of your environment like os, neovim version, python-neovim version.

Setting to DEBUG gives this:

22:05:47 INFO     __init__
22:05:53 INFO     Begin LanguageClientStart
22:05:53 INFO     End LanguageClientStart
22:05:53 INFO     Begin initialize
22:05:53 WARNING  Unknown project type. Fallback to use dir as project root.
22:05:53 INFO     rootPath: /Users/alokbeniwal/dev
22:05:53 DEBUG     => {"jsonrpc": "2.0", "method": "initialize", "params": {"processId": 49409, "rootPath": "/Users/alokbeniwal/dev", "rootUri": "file:///Users/alokbeniwal/dev", "capabilities": {}, "trace": "verbose"}, "id": 0}
22:06:02 INFO     textDocument/didChange
22:06:02 INFO     textDocument/didOpen
22:06:02 DEBUG     => {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"uri": "file:///Users/alokbeniwal/dev/isot.py", "languageId": "python", "version": 1, "text": "i"}}}
22:06:02 DEBUG     => {"jsonrpc": "2.0", "method": "textDocument/didChange", "params": {"textDocument": {"uri": "file:///Users/alokbeniwal/dev/isot.py", "version": 2}, "contentChanges": [{"text": "i"}]}}
22:06:02 INFO     Begin textDocument/completion
22:06:02 DEBUG     => {"jsonrpc": "2.0", "method": "textDocument/completion", "params": {"textDocument": {"uri": "file:///Users/alokbeniwal/dev/isot.py"}, "position": {"line": 0, "character": 1}}, "id": 1}

I'm running latest neovim, macOS 10.11.6, latest python-neovim (both 2 and 3).

Using this as my vimrc was enough to reproduce the problem.

let g:LanguageClient_serverCommands = {
    \'python' : ['pyls']
    \ }
source ~/.config/nvim/settings/language-server.vim
set rtp+=~/.config/nvim/bundle/LanguageClient-neovim

First, you are not using latest version.

Second,the example you are trying is too barebone. Try the example like https://github.com/autozimu/LanguageClient-neovim/blob/master/rplugin/python3/tests/sample-py/sample.py.

Also, completion might have small issues right now, try functions like LanguageClient_textDocument_definition() first.

How do you know I'm not using the latest version?

I installed the plugin onto a separate computer and I still don't see any of those functions, even after running UpdateRemotePlugins.

Several days ago, I've modified the initialization step. The didOpen notification shall only be sent after receiving initialization response. But from your log file though, no response received from server at all.

I almost run out of possible explanations for your case.

Perhaps, you can try a different language server cause I know the python language server you are referring is not mature enough yet.

I installed from vim-plug just yesterday. I've updated the plugin several
times since.
On Sun, Mar 5, 2017 at 3:58 PM Junfeng Li notifications@github.com wrote:

Several days ago, I've modified the initialization step. The didOpen
notification shall only be sent after receiving initialization response.
But from your log file though, no response received from server at all.

I almost run out of possible explanations for your case.

Perhaps, you can try a different language server cause I know the python
language server you are referring is not mature enough yet.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/autozimu/LanguageClient-neovim/issues/19#issuecomment-284274530,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AH8KTHzcKufK9N2Fy4FgTLpHPsd5oVedks5ri0wrgaJpZM4MTP7y
.

>

  • Alok

As last resort, you can copy the plugin manually to your neovim run time
path. Do 'UpdateRemotePlugins' to see if it helps.

On Sun, Mar 5, 2017 at 20:30 Alok Singh notifications@github.com wrote:

I installed from vim-plug just yesterday. I've updated the plugin several
times since.
On Sun, Mar 5, 2017 at 3:58 PM Junfeng Li notifications@github.com
wrote:

Several days ago, I've modified the initialization step. The didOpen
notification shall only be sent after receiving initialization response.
But from your log file though, no response received from server at all.

I almost run out of possible explanations for your case.

Perhaps, you can try a different language server cause I know the python
language server you are referring is not mature enough yet.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<
https://github.com/autozimu/LanguageClient-neovim/issues/19#issuecomment-284274530
,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/AH8KTHzcKufK9N2Fy4FgTLpHPsd5oVedks5ri0wrgaJpZM4MTP7y

.

>

  • Alok

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/autozimu/LanguageClient-neovim/issues/19#issuecomment-284281716,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABYt7ysDKlDrae1LsHxtVMDG4DH7zFizks5ri2G5gaJpZM4MTP7y
.

Closing as environment issue as it seems working well for others.

@autozimu Could you please add an example configuration for Python language server to the README?

It's just:
let g:LanguageClient_serverCommands = {'python': ['pyls']}

Was this page helpful?
0 / 5 - 0 ratings