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

bug: checkhealth doesn't work with Nixvim #1388

Open
erahhal opened this issue Feb 25, 2025 · 6 comments
Open

bug: checkhealth doesn't work with Nixvim #1388

erahhal opened this issue Feb 25, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@erahhal
Copy link

erahhal commented Feb 25, 2025

Describe the bug

I'm using Nixvim to configure Avante. It seems to work, but checkhealth is failing, saying that it can't find several plugins:

avante: require("avante.health").check()

avante.nvim ~
- ERROR Missing required plugin: stevearc/dressing.nvim
- OK Found required plugin: nvim-treesitter/nvim-treesitter
- ERROR Missing required plugin: nvim-lua/plenary.nvim
- ERROR Missing required plugin: MunifTanjim/nui.nvim
- OK Found icons plugin (nvim-web-devicons or mini.icons)

I believe these plugins are actually fine though. It seems that the path-based mechanism for testing plugins in the health check don't work with Nixvim (maybe Nix in general). Perhaps instead a load check would be better. This pattern works with Nixvim:

local function plugin_available(name)
  local check, _ = pcall(require, name)
  return check
end
.
.
.
if plugin_available(plugin.plugin_name) then
  ok(fmt("%s installed", plugin.name))
else
  error(fmt("%s not found", plugin.name))
end

To reproduce

Install Avante, nui, plenary, and dressing using Nixvim. Run checkhealth. Note that it fails.

Expected behavior

checkhealth passes.

Installation method

Use Nixvim:

{ config, ... }:
{
  programs.nixvim.plugins = {
    ## required dependencies
    dressing.enable = true;  # this is archived and may break in the future
    nui.enable = true;
    # plenary is included by other plugins

    ## optional dependencies
    cmp.enable = true;
    copilot-lua.enable = true;
    fzf-lua.enable = true;
    mini.enable = true;
    telescope.enable = true;
    web-devicons.enable = true;

    avante = {
      enable = true;

      settings = {
        provider = "copilot";
        cursor_applying_provider = "copilot";
        behaviour = {
          enable_cursor_planning_mode = true;
        };
      };
    };
  };
}

Environment

NVIM v0.10.4
Build type: Release
LuaJIT 2.1.1713773202

NixOS Unstable
x86

Repro

Unfortunately I don't know how to get the init.lua generated by Nixvim. In any case, it's not really important to this issue.
@omarcresp
Copy link
Contributor

You must configure copilot, try doing :Copilot auth and then restart nvim, if you setup copilot this error should go

bonus:

  • nixvim includes an executable nixvim-print-init that you can use to debug the result init.lua
  • nixvim is a package manager, means you dont need to manually handle the required dependencies of most plugins
  • fzf-lua, telescope and mini are a case of "choose one" and then you have to register in avante config which file selector provider you want to use
    I recommend you using this setup:
{
  plugins = {
    cmp.enable = true;
    copilot-lua.enable = true;
    mini = {
      enable = true;
      modules.pick = {};
    };
    web-devicons.enable = true;

    avante = {
      enable = true;

      settings = {
        provider = "copilot";
        cursor_applying_provider = "copilot";
        behaviour = {
          enable_cursor_planning_mode = true;
        };
        file_selector = {
          provider = "mini.pick";
        };
      };
    };
  };
}

@erahhal
Copy link
Author

erahhal commented Feb 25, 2025

I think you missed the details in my report. Avante is working fine, using copilot. The problem is not with using or configuring Avante, just the checkhealth call. I put a link to the exact lines in Avante's health check with the problem.

@omarcresp
Copy link
Contributor

oh my bad, i was automated mode... Yeah it looks like it could be a deeper issue with the way the health script determines whether a dep is present... ill give it a look if the issue is in there

@omarcresp
Copy link
Contributor

This nixpkgs version will contain the fix. If you are using nixpkgs unstable the next couple days you should receive the update
NixOS/nixpkgs#385493

@erahhal
Copy link
Author

erahhal commented Feb 27, 2025

Awesome, thank you!

@MattSturgeon
Copy link

Just as an FYI, there's currently unrelated issues in nixpkgs that are causing nixvim to hold back its supported nixpkgs revision (nix-community/nixvim#2991).

To get the avante fix, you can either use multiple nixpkgs inputs and specify plugins.avante.package explicitly, or use flake input follows to ignore nixvim's specified nixpkgs revision, although doing this may cause you to run into the same issues we're seeing in nix-community/nixvim#2991.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants