Open korken89 opened 1 year ago
It seems like the get_root_dir
is not called like a co-routine.
It seems like the
get_root_dir
is not called like a co-routine
@korken89 Indeed, though it seems that it's only a coroutine for rust-analyzer? (Or at least isn't a coroutine for a few other server configs). I'm not sure if there's some way to dynamically detect if that a lspconfig function is a coroutine or not.
This patch fixes the issue, it could be made conditional on server_name == "rust_analyzer"
:
diff --git a/lua/nlspsettings/command/init.lua b/lua/nlspsettings/command/init.lua
index 7454afe..1b21972 100644
--- a/lua/nlspsettings/command/init.lua
+++ b/lua/nlspsettings/command/init.lua
@@ -113,7 +113,11 @@ M.open_local_config = function(server_name)
local conf = config.get()
local root_dir
if lspconfig[server_name] then
- root_dir = lspconfig[server_name].get_root_dir(path.sanitize(start_path))
+ local sanitized_start_path = path.sanitize(start_path)
+ local coro = coroutine.wrap(function()
+ return lspconfig[server_name].get_root_dir(sanitized_start_path)
+ end)
+ root_dir = coro()
end
if not root_dir then
but I'm not sure if there's a reason why this plugin calls lspconfig[server_name].get_root_dir()
in the first place instead of vim.lsp.buf.list_workspace_folders()
and using the first item? Is there a semantic difference between those?
Alternatively there's also vim.lsp.get_client_by_id(client_id).config.root_dir
, which gets the root directory the LSP was started with (which should be set by lspconfig).
Hi @Qyriad, thank you for the input! My LUA knowledge is rock-bottom-bad, but I really want this plugin to work. I do a lot of embedded and backend work in Rust, and those need different configuration of the LSP to make it work.
With that said I tried getting the original command to work in a fork: https://github.com/tamago324/nlsp-settings.nvim/commit/72921a712b37476abc1cc465e577e796c82d7069
I got the async_run
from Neovim's lspconfig, and wrapped the entire call in it.
I was able to make it run without error, however it never loaded the LSP config. At that point I paused.
Your idea on using list_workspace_folders()
is intriguing, I'll try to wrap my head around how I can use that in stead.
If you have any feedback I'd love to hear it!
Edit: I tested your fix here: https://github.com/korken89/nlsp-settings.nvim/tree/fix2
Or, I should say it seem to be semi working?
The issue I am seeing is that if I set the global config to the same config as I set in the local file, I see different results.
What happens if you configure the embedded LSP wrong, an rustc
process gets stuck at 100% for a few minutes.
If I set the correct config in the global config, this does not happen. If I set the correct config in the local config, it does happen.
I also the the print saying that the LSP configuration has been updated if I do update the local LSP config [Lsp Settings] [rust-analyzer] Success to update the settings.
, so it seems to be working?
Maybe I'm hitting some other but than one in nlsp-settings
?
I can also see what is going wrong, with the following config:
{
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.extraArgs": ["--bin", "app"]
}
cargo check
is still called with the --all-tagets
flag.
So it seems like the settings don't stick?
Alright, I have gotten close to the root of the issue and I can get the local config to work with a caveat. Here are my steps:
This looks like a race to me between my global config and my local config. What does anyone else think?
Here is my global config for reference: https://github.com/korken89/nvim-config/blob/master/after/plugin/lspconfig.lua
Alright, I have gotten close to the root of the issue and I can get the local config to work with a caveat. Here are my steps:
- If I open a project with a local config, the local config is not used - the global config is used.
- If I open the local config and save it, everything starts working.
This looks like a race to me between my global config and my local config. What does anyone else think?
Here is my global config for reference: https://github.com/korken89/nvim-config/blob/master/after/plugin/lspconfig.lua
Hi ! I facing the same issue, any update on it? PS: Also, what do you mean by "open the local config and save it"?
Hi!
I'm trying to give this plugin a try, but I am getting the following error when running
:LspSettings local rust_analyzer
:My current config is (use default config):
I'm not sure what's going wrong but it seems to be an internal error to the plugin. Any assistance would be appreciated!