-
Notifications
You must be signed in to change notification settings - Fork 24
LSPs stop working when running in a devenv environment #268
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
Comments
As a workaround, after a few hours of digging around I found that adding the LSP to the devenv fixes the issues. It definitively smells like path issue, which is odd as the LSP do show up in nvim if I do |
So, installing lsps to the dev shell is actually very common as sometimes the version of the language used in the project is different fro the one you installed in your nvim. NixCats suffixes the path with the items in lspsAndRuntimeDeps by default so that by default nvim will inherit the lsp from the shelll instead of itself if provided, and otherwise fall back to the items provided by nixCats. Unfortunately, this also means people can also run into environment issues by default. You should double check that the shell isn't adding things you aren't expecting (many of the devenv options do actually install the lsp alongside the language by default) First thing to try you can make nixCats prefix the path with its items instead of suffix. This should make the ones provided by nixCats always win out over ones provided from other sources. You can either change the default for all items in lspsAndRuntimeDeps by setting If this works, you should make sure you aren't installing a version of tailwindcss-language-server somewhere else that is not compatible with the project for some reason. |
but you say its ALL lsps, with a blank devenv shell? That is definitely odd. Because in that case, devenv shouldnt be installing anything that overrides the one from nixCats? I dont know of any reason why nixCats would work any differently inside a devenv shell? NixCats is a simple wrapper script, it literally just adds stuff to the environment before launching nvim. I dont know why that would work differently inside a devenv shell. I dont use devenv much, I only really use it when I load other peoples projects that do. I havent noticed this, but I will check it out again and see if I can reproduce this. For what its worth, it seems to behave appropriately in a normal dev shell. But yeah please let me know if changing it to prefix the path solves the issue. |
Ok. I ran ran Then I did All my nixCats provided lsps work still inside the shell (without doing prefix) I tested nix rust lua go and bash lsps inside the shell, they all worked. So it doesnt happen in a blank I also tried enabling languages.go in the devenv shell and that seems to not break things? So hopefully setting it to prefix those lsps to the path instead of suffix will fix things for you, as then in theory the one you should be running then would always be the one provided from nixCats because the wrapper script you launch nvim with prefixes the path with them on startup, rather than suffixing the path with them. Its also possible the lsp requires a compiler of the matching version on the path, in which case installing it via the dev shell is often what you want, as otherwise you would need to also install the compiler via nixCats and prefix that as well so you can make sure they have the same version, which may not always match the one your project needs. Rust can be like this sometimes. I have nixCats suffix the rust stuff in my config for when I have no shell and let the shell provide its own for the project which then overrides my one from nixCats, because installing a toolchain provides an lsp in rust by default, so its honestly easier to do that than to not do it. |
in particular, personally after trying --prefix vs --suffix to see if that fixes it, I would start my debug search by looking at what these provide. You may find that they are providing the lsps, but doing so in a way incompatible with your current lua lsp configuration, or that they dont provide the lsp, but they provide a compiler incompatble with your lsp provided via nixCats, and your lsp is failing trying to use it. languages = {
erlang.enable = true;
elixir.enable = true;
}; from devenv's code config = lib.mkIf cfg.enable
{
git-hooks.hooks = {
credo.package = cfg.package;
dialyzer.package = cfg.package;
mix-format.package = cfg.package;
mix-test.package = cfg.package;
};
packages = with pkgs; [
cfg.package
elixir_ls
];
}; Looks like they install elixir_ls and also looks like they install erlang-ls config = lib.mkIf cfg.enable
{
packages = [
cfg.package
pkgs.erlang-ls
rebar3
];
}; So, your nixCats isnt working because those are being found instead and for some reason with your lua config that isnt ok? Hopefully setting it to prefix them is all you need here, and if not hopefully this gives you the info needed to debug this and figure out what else needs to be included or what is going wrong :) If you figure it out, please update us here and I can convert it to a discussion to help others with the same issue. If you don't figure it out we can of course continue to explore further. |
Hey, love the project! thanks for all the work on this!
I'm hitting one issue that prevents me from switching to nix cats for good: none of my LSPs (e.g., elixir-ls) are working when inside a devenv shell.
For example:
devenv init
in a repo.It feels like a PATH issue or something about the shell environment devenv sets up, but I haven’t been able to pinpoint it, and the logs haven't been helpful.
I've noticed that the path (such as elixir-ls) are different when .devenv is present.
I understand this repo may not support devenv, but I’m wondering if you’ve run into this before or could offer any debugging tips.
It’s the last hurdle I need to fully switch to nix cats and devenv.
Thanks in advance!
The text was updated successfully, but these errors were encountered: