Nvim-lspconfig: Pyls not reporting errors (or almost any diagnostics)

Created on 13 Oct 2020  路  2Comments  路  Source: neovim/nvim-lspconfig

  • nvim --version:
NVIM v0.5.0-751-gd198aa511
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-7fcf59ed-01e6-4dcf-a363-4c9cb0163aca


Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info
  • :checkhealth result
health#nvim_lsp#check
========================================================================
## Checking language server protocol configuration
  - INFO: pyls: configuration checked.
  - INFO: rust_analyzer: configuration checked.
health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $COLORTERM='truecolor'
  • nvim-lsp version(commit hash): 60133c47e0fd82556d7ca092546ebfa8d047466e
  • What language server: pyls 0.34.1-2
  • Operating system/version: Arch Linux
  • Terminal name/version: alacirtty 0.5.0
  • $TERM: xterm-256color

How to reproduce the problem from neovim startup

init.vim
---------

call plug#begin($HOME.'/.config/nvim/autoload/plugged')
Plug 'neovim/nvim-lspconfig' 
Plug 'nvim-lua/diagnostic-nvim' 
call plug#end()

lua <<EOF

require'nvim_lsp'.pyls.setup{on_attach=require'diagnostic'.on_attach}
require'nvim_lsp'.rust_analyzer.setup{on_attach=require'diagnostic'.on_attach}

EOF

let g:diagnostic_enable_virtual_text = 1
let g:space_before_virtual_text = 20

Create a random python file and write some gibberish:
python

Actual behaviour

As you can see, there are no syntax errors, mismatched brackets, "no member" errors etc. In fact I have been unable to force it to show anything other than whitespace warnings (like "trailing whitespace", "expected indentation block" or "expected 2 empty lines and found 1" ).

Expected behaviour

There should be an error in pretty much every single line above. Compare it to what happens with __rust_analyzer__:
rust

Now, if I add the lsp-status plugin and run

:echo luaeval("require('lsp-status').diagnostics()")

I also only get the 1 warning in that ridiculous python file, which (combined with the fact that rust works just fine) leads me to belive the problem is in the language server itself. Any advice on how to fix this?

bug

Most helpful comment

I suspect it's because of how you installed the server. Note that pyls leans on pylint, pyflakes, pycodestyle and pydocstyle for diagnostics. But these aren't installed by default.

You can use something like pip3 install 'python-language-server[all]' to install all its dependencies. Alternatively install the linters you're interested in manually.

All 2 comments

I suspect it's because of how you installed the server. Note that pyls leans on pylint, pyflakes, pycodestyle and pydocstyle for diagnostics. But these aren't installed by default.

You can use something like pip3 install 'python-language-server[all]' to install all its dependencies. Alternatively install the linters you're interested in manually.

Hey, thank you so much for the quick reply. You are correct, after installing flake8 the code is linted the way it should. I had pylint installed already and thought that it would be sufficient by itself. Thanks again!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RefusesNames picture RefusesNames  路  3Comments

nomasprime picture nomasprime  路  5Comments

nhooyr picture nhooyr  路  3Comments

JamesGreenaway picture JamesGreenaway  路  9Comments

agriffis picture agriffis  路  5Comments