Cmp-nixpkgs: two nvim-cmp completion sources for nixpkgs

Mostly a holdout until https://github.com/nix-community/rnix-lsp gets autocompletion support for attributes and nixos modules.

This is a simple wrapper around NIX_GET_COMPLETIONS=3 nix eval --read-only self#foo.bar that currently makes some assumptions about how nix/nixos is configured, see the README and source code for more.

It’s split into two sources:

  • nixpkgs, for pkgs, lib, and config.
  • nixos, for nixos modules.

The sources have some support for nested attributes by leveraging tree-sitter to get the surrounding context for the node at cursor, however this can be somewhat fragile.

Link: https://github.com/gravndal/cmp-nixpkgs

3 Likes
Hosted by Flying Circus.