Closed silentjay closed 2 years ago
Do pylsp_black
and pyls_isort
run, if you remove pylsp_mypy
?
Meaning: Is this a problem specific to this plugin?
No they don't run, or at least not what I can tell...e.g. I can run the formatting command with the black plugin installed and the code does get formatted but have no idea if it's black formatting the code or something else.
At the same time the other plugins such as flake8
, mccabe
, pydocstyle
etc do 100% run fine and I can toggle them on and off.
How am I meant to debug pylsp-mypy
? All these pylsp
plugins seem like black boxes to me.
The programs that work have the same install locations:
> which flake8
/home/me/.local/bin/flake8
> which pydocstyle
/home/me/.local/bin/pydocstyle
I assume it's therefor the actual 3rd party plugin code not happy about something?
OK just tried enabling/disabling pylsp_black
and running the format command, and it's definitely black
doing the formatting as no formatting occurs once pylsp_black
is disabled. So looks like it is an pylsp-mypy
specific issue I'm having.
Some extra version info:
> mypy --version
mypy 0.950 (compiled: yes)
> pylsp --version
pylsp v1.4.1
There are log files, but their location depends on how you run the language server
The language server runs the plugins as subprocesses, by looking at your running processes you can usually find which python process is pylsp-mypy. For there you can bind a console to the output stream of that process and get the log this way.
I assume -- speedup
is a comment?
Maybe try removing that.
Also live_mode and dmypy cannot work together. If both are set active live_mode is automatically disabled. This should not cause an issue but maby its worth trying if changing this helps.
For further ideas, I need logs.
Thanks for your help, I did try remove the comment and remove the other options such as live_mode previously without any luck.
Your comment about the processes however made me fire up htop
and try to hunt down pylsp-mypy
, where I discovered pylsp
is running in it's own venv which I had no idea about:
So I simply activated the venv, ran pip install pylsp-mypy
again and now pylsp-mypy
works as expected!
Not really sure why I have to activate the pylsp
venv and then install the plugin, there's no mention of having to do this on the pylsp
docs. It must be something to do with nvim-lsp-installer
which I used to installed pylsp
.
Well, it is sensible, that pylsp only loads plugins installed in the same environment (in fact it would be terrible if this where not the case).
Venvs can be a little tricky but pylsp and pylsp-mypy handle them well (by now).
The reason why pylsp doc does not mention this is, that usually you are the one managing your venvs and of course you would install the server and the plugin in the same venv, which works.
It is a bit odd, that the installer you used made a seperate venv for pylsp (there are probably good reasons). Thats why they have this: https://github.com/williamboman/nvim-lsp-installer/tree/main/lua/nvim-lsp-installer/servers/pylsp#readme
Most such installers just install all third party plugins so that no such issues occure (which likely explains why this readme is this well hidden), however due to the fact pylsp-mypy is newer than the others it might not be included everywhere (or has not been when you ran the installer)
hi @Richardk2n , I can't get this to work with neovim lsp. I installed with nvim-lsp-installer . Here is my lspconfig:
lspconfig.pylsp.setup {
on_attach = on_attach,
capabilities = capabilities,
settings = {
pylsp = {
configurationSources = { 'flake8' },
plugins = {
flake8 = { enabled = true },
black = { enabled = true },
pylsp_mypy = { enabled = true, live_mode = true },
pycodestyle = { enabled = false },
pyflakes = { enabled = false },
mccabe = { enabled = false },
},
},
},
}
PyLSP version is 1.5.0, and pylsp-mypy is 0.6.2. Flake8 and black work as expected, but there is no diagnostic for mypy
@sandangel ensure pylsp-mypy is installed in the correct venv, see my previous comments. If it is installed correctly then open a new issue as my configuration problem was resolved and this issue closed.
@silentjay they are installed in the same venv using nvim-lsp-install
. could you share your current config with pylsp 1.5.0 and pylsp-mypy 0.6.2?
hmm, I think this is more like because I'm using nixos. 🥲
No luck getting this plugin to run, I've installed
pylsp-mypy
globally withpip install pylsp-mypy
, same aspylsp
andmypy
:My init.vim:
Running neovim from inside the project venv or not in a venv makes no difference. I don't know if it's related but from what I can tell neither
pyls_isort
norpylsp_black
run either, although the others such asmccabe
andflake8
do. (UPDATE -pylsp_black
does run as expected)