Skip to content

[HELP] Assistance with nixd configuration in nixvim #4206

@fjtluz

Description

@fjtluz

I've decided to learn to use nix to help me configure my configurations. I am using home-manager with flakes; also I am on Fedora on a single-user installation of nix. I am familiar vim and nvim, but I've only ever used them with coc and wanted to try configuring the lsp's directly through nix.
As a first step config in my nix file, I should install nixvim and configure the lsp for nixd, as to facilitate my configuration. And second, I should configure cmd to give me basic completions.
But I don't seem to be able to get nixd to run for home-manager and nixvim. For nixpkgs it gives suggestions just fine, but for the others I am left in the dark.

I apologize for opening an issue just for helo, and if there's a better community forum for this types of questions, I'll gladly move there.
I've gone through a bit of the issues and tried the solutions posed on #2290, but they weren't able to solve my problem.

Here is my base flake.nix:

{
  description = "Home Manager configuration of fjtluz";

# nixpkgs, home-manager and flake-parts are imported by default
  inputs = {
    nixvim.url = "github:nix-community/nixvim";
  };
  outputs = inputs@{
    flake-parts,
      home-manager,
      nixpkgs,
      ...
  }:
  flake-parts.lib.mkFlake { inherit inputs; } {
    imports = [
      inputs.home-manager.flakeModules.home-manager
    ];
    systems = [
      "x86_64-linux"
    ];
    flake = {
      homeModules.home = { pkgs, ... }: {
        home.username = "fjtluz";
        home.homeDirectory = "/home/fjtluz";
        home.stateVersion = "25.11";
        home.packages = with pkgs; [
          nixd
            nixfmt
        ];
        programs.home-manager.enable = true;
        nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
      };
      homeModules.nixvim = 
      {
        imports = [ 
          inputs.nixvim.homeModules.nixvim
        ];
        programs.nixvim = {
          enable = true;
          imports = [
            ./nixvim
          ];
        };
      };
      homeConfigurations.fjtluz = home-manager.lib.homeManagerConfiguration {
        pkgs = import nixpkgs { system = "x86_64-linux"; };
        modules = [
          inputs.self.homeModules.home
            inputs.self.homeModules.nixvim
        ];
      };
    };
  };
}

And here is the default.nix inside ./nixvim:

{
  config = {
    colorschemes.everforest = {
      enable = true;
      settings = {
        colors_override = {
          bg0 = [ "#1C1C1C" "235" ];
        };
      };
    };

    opts = {
      tabstop = 2;
      shiftwidth = 2;
      expandtab = true;
      softtabstop = 2;
    };

    viAlias = true;
    vimAlias = true;

    plugins.lsp = {
      enable = true;
      servers.nixd = {
        enable = true;
        settings = 
        let
          flake = "(builtins.getFlake \"/home/fjtluz/.config/home-manager/\")";
          home-manager-options = "${flake}.homeConfigurations.fjtluz.options";
        in
        {
            nixpkgs = { expr = "import <nixpkgs> { }"; };
            formatting = { command = "nixfmt"; };
            options = {
              flake-parts = "${flake}.debug.options";
              home-manager = "${home-manager-options}";
              nixvim = "${home-manager-options}.programs.nixvim.type.getSubOptions [ ]";
            };
        };
      };
    };

    lsp = {

      keymaps = [ 
      { key = "gd"; lspBufAction = "definition"; } 
      ];
    };

    plugins = {
      cmp = {
        enable = true;
        autoEnableSources = true;
        settings.sources = [
        { name = "nvim_lsp"; }
        ];
      };
    };
  };
}

As I mentioned above, I receive suggestions for nixpkgs just fine:

Image

But for programs, the suggestions seem really random and don't really reflect programs I would be able to install (e.g. fish, kitty)

Image

And for programs.nixvim, simply nothing at all:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions