Skip to content

neovim: let nixd resolve nixpkgs for hover / go-to-definition #344

Description

@etrobert-bot

Goal

Make the nixd LSP resolve symbols from nixpkgs so hover and go-to-definition work on pkgs.* references (e.g. hovering pkgs.ripgrep or jumping into a package definition).

Background

pkgs/neovim-wrapped/plugins/lspconfig/config.lua configures nixd with settings.nixd.options (nixos/darwin option sets) but no settings.nixd.nixpkgs.expr. Per nixd's configuration, nixpkgs.expr provides the package set nixd evaluates for completion/hover/definition on pkgs.*; without it nixd has no nixpkgs data. (nixd docs: docs/configuration.md, key nixpkgs.expr, default import <nixpkgs> { }.)

Plan

  • Add a nixpkgs block alongside the existing options block in the nixd settings:
    nixpkgs = {
      expr = "import (builtins.getFlake (builtins.toString ./.)).inputs.nixpkgs { }",
    },
    This reuses the flake's own nixpkgs input rather than a <nixpkgs> channel lookup, consistent with the existing options.*.expr values and with the repo's flake-native Nix style (no <nixpkgs>).

Verification

  • nix build .#neovim-wrapped succeeds.
  • Lua config remains syntactically valid (loads in headless nvim without error).
  • Manual: in a nix file, hover over a pkgs.<name> reference resolves (noted as a manual step; headless LSP hover is hard to assert in CI).

From the linux todo list: "Make is so that nixd can find stuff from the store, for example on hover or go to definition".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions