Open felix-clark opened 1 year ago
In :MasonLog
I do see some lines like the following:
[ERROR Fri 14 Oct 2022 11:02:26 AM EDT] ...er/opt/mason-lspconfig.nvim/lua/mason-lspconfig/init.lua:19: Failed to set up lspconfig integration. ...on-lspconfig.nvim/lua/mason-lspconfig/lspconfig_hook.lua:51: module 'lspconfig.util' not found:
Ok, I figured out the cause of my problem.
The mason-lspconfig readme instructs to set up mason-lspconfig before nvim-lspconfig. However, mason-lspconfig's setup() function indirectly requires "lspconfig.util", meaning that nvim-lspconfig must be loaded, if not "set up", before mason-lspconfig.setup() is called.
Now I'm using Packer to load in the following order: 1) mason.nvim 2) mason-lspconfig.nvim 3) nvim-lspconfig, but then calling require("mason-lspconfig").setup({})
not when mason-lspconfig.nvim
is loaded, but only when I configure nvim-lspconfig.
I'm leaving this open for now because IMO this could be explained a little more clearly in the documentation, but as far as I can tell this isn't an actual bug otherwise.
I'm not sure I've actually completely solved the issue, because some additional plugins installed with PylspInstall
cause the python LSP client to crash. For instance, flake8
cannot be found despite being visible and present in the venv. It's as if pylsp is not properly using the virtual environment it's setting up.
I'm not sure I've actually completely solved the issue, because some additional plugins installed with
PylspInstall
cause the python LSP client to crash. For instance,flake8
cannot be found despite being visible and present in the venv. It's as if pylsp is not properly using the virtual environment it's setting up.
I am having the same issue with flake8 under pylsp:
[ERROR][2022-12-21 14:13:11] .../vim/lsp/rpc.lua:734 "rpc" "pylsp" "stderr" "2022-12-21 14:13:11,079 CST - WARNING - pylsp.config.config - Failed to load hook pylsp_lint: [Errno 2] No such file or directory: 'flake8'\nTraceback (most recent call last):\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pylsp/config/config.py\", line 33, in _hookexec\n return self._inner_hookexec(hook_name, methods, kwargs, firstresult)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pluggy/_manager.py\", line 327, in traced_hookexec\n return outcome.get_result()\n ^^^^^^^^^^^^^^^^^^^^\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pluggy/_result.py\", line 60, in get_result\n raise ex[1].with_traceback(ex[2])\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pluggy/_result.py\", line 33, in from_call\n result = func()\n ^^^^^^\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pluggy/_manager.py\", line 324, in <lambda>\n lambda: oldcall(hook_name, hook_impls, kwargs, firstresult)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pluggy/_callers.py\", line 60, in _multicall\n return outcome.get_result()\n ^^^^^^^^^^^^^^^^^^^^\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pluggy/_result.py\", line 60, in get_result\n raise ex[1].with_traceback(ex[2])\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pluggy/_callers.py\", line 39, in _multicall\n res = hook_impl.function(*args)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pyls_flake8/plugin.py\", line 127, in pylsp_lint\n p = run_flake8(args, document)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/pyls_flake8/plugin.py\", line 121, in run_flake8\n return run(args, stdout=PIPE, stderr=PIPE, input=document.source.encode())\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/mkeisler/.pyenv/versions/3.11.0/lib/python3.11/subprocess.py\", line 546, in run\n with Popen(*popenargs, **kwargs) as process:\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/mkeisler/.pyenv/versions/3.11.0/lib/python3.11/subprocess.py\", line 1022, in __init__\n self._execute_child(args, executable, preexec_fn, close_fds,\n File \"/home/mkeisler/.pyenv/versions/3.11.0/lib/python3.11/subprocess.py\", line 1899, in _execute_child\n raise child_exception_type(errno_num, err_msg, err_filename)\nFileNotFoundError: [Errno 2] No such file or directory: 'flake8'\n"
14:26:03 ❯ ls -d /home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/flake8
/home/mkeisler/.local/share/nvim/mason/packages/python-lsp-server/venv/lib/python3.11/site-packages/flake8
Hey, forgot to reply here before.
The mason-lspconfig readme instructs to set up mason-lspconfig before nvim-lspconfig. However, mason-lspconfig's setup() function indirectly requires "lspconfig.util", meaning that nvim-lspconfig must be loaded, if not "set up", before mason-lspconfig.setup() is called.
I believe this might've been fixed since?
I'm leaving this open for now because IMO this could be explained a little more clearly in the documentation, but as far as I can tell this isn't an actual bug otherwise.
Would you say the current README and :h mason-lspconfig-requirements
explains it more clearly?
I believe this might've been fixed since?
I'm not sure this is what you mean by "fixed" but it appears that require("mason-lspconfig").setup{}
does still need require("lspconfig")
to be called first, otherwise I still get the error about needing lspconfig.util
.
Would you say the current README and :h mason-lspconfig-requirements explains it more clearly?
To be honest, the README on its own would still not really clarify the issue for me. I would still try to call require("mason-lspconfig").setup{}
before loading nvim-lspconfig at all. I think part of the source of confusion is the ambiguity in the term "set up" - does this mean first require
ing the package, or calling its setup()
function? In many cases these happen at the same time, but in this particular case the difference matters.
The help page is a little better because of the note, but it still may not be the most clear for inexperienced users. For instance, I'm not familiar with "rtp", so while the meaning is clear to me with hindsight of the issue, I'm not sure it would be as clear up front.
Would it make sense to add a step in the instructions, i.e. conceptually:
This is admittedly colored by my personal biases, conventions, and expectations but hopefully it illustrates what threw me off.
Problem description
Despite calling
require("mason-lspconfig").setup()
(in Packer's config field for mason-lspconfig.nvim) and installingpylsp
viaLspInstall
, the:PylspInstall
command to install extra pylsp features is not available in a python buffer. The LSP is otherwise attached and setup properly as far as I can tell.I am reasonably confident that
require("mason-lspconfig").setup()
is indeed being called, because I have the lua language server listed underensure_installed
and it is re-installed when starting neovim after I manually uninstall it.Perhaps there is a problem with my config, but I just had this working in
nvim-lsp-installer
and it's not clear what I would be missing. Is there guidance on how to debug this issue?Why do you think this is an issue with mason-lspconfig.nvim?
I'm not positive that it is - it could be an issue with my config - but based on my reading of the documentation it's not clear what I could be missing.
Neovim version (>= 0.7)
NVIM v0.8.0-1210-gd367ed9b2 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3
Operating system/version
Linux 5.4.0-128-generic #144-Ubuntu SMP Tue Sep 20 11:00:04 UTC 2022 x86_64
I've manually reviewed the Nvim LPS client log (
:LspLog
) to find potential errorsI've recently downloaded the latest plugin version of mason.nvim, mason-lspconfig.nvim, and nvim-lspconfig
Affected language servers
pylsp
Steps to reproduce
:LspInstall pylsp
to install the python language server:PylspInstall
.Actual behavior
The
PylspInstall
command to install addons to pylsp is not available or recognizedExpected behavior
I'd expect to be able to use
:PylspInstall
as I could withnvim-lsp-installer
LspInfo
LspLog
Healthcheck
Screenshots or recordings
No response