emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.81k stars 892 forks source link

Autocompletion options for Nix (nixd) #4593

Closed breitnw closed 1 month ago

breitnw commented 1 month ago

This PR adds more comprehensive options for the nixd language server, including those necessary for formatting and completion. As mentioned in #4592, these options were previously absent.

The options added include:

An example configuration in Doom:

(after! lsp-mode
  (setq lsp-nix-nixd-formatting-command [ "nixfmt" ]
        lsp-nix-nixd-nixpkgs-expr "import <nixpkgs> { }"
        lsp-nix-nixd-nixos-options-expr "(builtins.getFlake \"/home/breitnw/Documents/code/nixos\").nixosConfigurations.mnd.options"
        lsp-nix-nixd-home-manager-options-expr "(builtins.getFlake \"/home/breitnw/Documents/code/nixos\").homeConfigurations.\"breitnw@mnd\".options"))

(add-hook! 'nix-mode-hook
           (setq company-idle-delay 0.1))
psibi commented 1 month ago

Thank you!