HallerPatrick / py_lsp.nvim

Lsp Plugin for working with Python virtual environments
100 stars 12 forks source link

Incompatible with LSP installed by LspInstall #5

Open d-miketa opened 3 years ago

d-miketa commented 3 years ago

https://github.com/kabouzeid/nvim-lspinstall is a convenient plugin to install LSP servers. They end up in a separate directory outside of $PATH (~/.local/share/nvim/lspinstall/python/./node_modules/.bin/pyright-langserver in my case), but https://github.com/kabouzeid/nvim-lspinstall/blob/54b439241e83e0a9ce8f6bcdf3b2c560a2328792/lua/lspinstall.lua#L94 corrects the default cmd for lspconfig to point to that location. However py_lsp doesn't pick up on it for some reason, perhaps overriding cmd or cmd_cwd in default_config?

This is with py_lsp installed and used to set up Pyright:

image image

And this is with py_lsp disabled: (note cmd)

image
HallerPatrick commented 3 years ago

@d-miketa Hey thank you for your response and sorry for responding so late.

I could indeed reproduce that behaviour. The problem here is not that the language server is not found, but the way lspconfig tries to call it.

The lspinstall README says to use following snippet for initialising the install server:

require'lspinstall'.setup() -- important

local servers = require'lspinstall'.installed_servers()
for _, server in pairs(servers) do
  require'lspconfig'[server].setup{}
end

The servers table includes the name of the language, not the name of the language server, something like {"rust", "python", "lua"}.

So in the end what is called is:

require'lspconfig'['python'].setup()

where cmd is accordingly updated for the custom install path.

and not:

require'lspconfig'['pyright'].setup()

I will probably put in some checks and look that "python" is passed to lspconfig and not "pyright" when it is installed through lspInstall

HallerPatrick commented 2 years ago

Still not working...