Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction between preferred_servers and excluded_servers has changed a bit recently #39

Closed
metiulekm opened this issue Apr 21, 2024 · 1 comment

Comments

@metiulekm
Copy link
Contributor

So I had something like this in my config:

-- rust_analyzer setup via nvim-lspconfig

require("lazy-lsp").setup {
    excluded_servers = {
		"rust_analyzer",
	}
    preferred_servers = {
        rust = { "rust_analyzer" },
	}
}

The intention behind this weird piece of config was that I wanted to setup rust_analyzer manually, essentially due to #22. But back when I was writing this config, there was also the legacy Rust language server, RLS, which I wanted to exclude. And at the time, I wanted to use preferred_servers to set my preferred servers instead of excluding those that I did not want (not unlike #23 (comment)).

In the past, this worked exactly as I wanted: lazy-lsp would not setup rust_analyzer because I have excluded it, and would also setup nothing else for this filetype because of the preferred_servers value. So in the end, lazy-lsp would not do anything for the rust filetype.

However, some time ago, lazy-lsp started instead setting up a second copy of rust-analyzer. I did not investigate this very deeply, but I suspect this is due to 26c681f. If I understand correctly, on the left side we iterate on included_servers, which takes excluded_servers into account. However, on the right side, we iterate on server_to_filetypes, which also takes preferred_servers into account.

In the end, I just switched to using prefer_local (thanks a lot! ❤️). Also I changed my mind on excluded_servers/preferred_servers, and you have removed RLS configuration anyway. And even then I will be first to admit that the snippet I pasted looks kind of absurd, so I won't be surprised if you just close the issue immediately 😛 But I do feel the previous behavior is slightly more correct, and I just wanted to create this issue to not throw away information.

@dundalek
Copy link
Owner

Thanks, I appreciate the write-up.

Getting these options to cover needed situations without getting too overwhelming is a journey :)

You are correct, I was able to verify with a new test case that there was indeed a regression and matches the commit you found. I also find the previous behavior more intuitive.

Glad to hear the new option works for you even better with a cleaner config. I think I will push a fix anyway to get a peace of mind :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants