Skip to content

Commit

Permalink
Autocompletion options for Nix (nixd) (#4593)
Browse files Browse the repository at this point in the history
* Nix autocompletion options

* Support for formatting with nixd

* Revert nixd lsp name
  • Loading branch information
breitnw authored Oct 25, 2024
1 parent 27d6e79 commit 1c407ec
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions clients/lsp-nix.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,57 @@
:type 'string
:package-version '(lsp-mode . "8.0.0"))

(lsp-defcustom lsp-nix-nixd-formatting-command nil
"External formatter command with arguments.
Example: [ \"nixpkgs-fmt\" ]"
:type 'lsp-string-vector
:group 'lsp-nix-nixd
:lsp-path "nixd.formatting.command"
:package-version '(lsp-mode . "9.0.1"))

(lsp-defcustom lsp-nix-nixd-nixpkgs-expr nil
"This expression will be interpreted as \"nixpkgs\" toplevel
Nixd provides package, lib completion/information from it.
Resource Usage: Entries are lazily evaluated, entire nixpkgs takes 200~300MB
for just \"names\". Package documentation, versions, are evaluated by-need.
Example: \"import <nixpkgs> { }\""
:type 'string
:group 'lsp-nix-nixd
:lsp-path "nixd.nixpkgs.expr"
:package-version '(lsp-mode . "9.0.1"))

(lsp-defcustom lsp-nix-nixd-nixos-options-expr nil
"Option set for NixOS option completion. If this is omitted, the default
search path (<nixpkgs>) will be used.
Example:
\"(builtins.getFlake \"/home/lyc/flakes\").nixosConfigurations.adrastea.options\""
:type 'string
:group 'lsp-nix-nil
:lsp-path "nixd.options.nixos.expr"
:package-version '(lsp-mode . "9.0.1"))

(lsp-defcustom lsp-nix-nixd-home-manager-options-expr nil
"Option set for home-manager option completion.
Example:
\"(builtins.getFlake \"/home/lyc/flakes\").nixosConfigurations.adrastea.options\""
:type 'string
:group 'lsp-nix-nil
:lsp-path "nixd.options.home-manager.expr"
:package-version '(lsp-mode . "9.0.1"))

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-nix-nixd-server-path))
:major-modes '(nix-mode nix-ts-mode)
:initialized-fn (lambda (workspace)
(with-lsp-workspace workspace
(lsp--set-configuration
(lsp-configuration-section "nixd"))))
:synchronize-sections '("nixd")
:server-id 'nixd-lsp
:priority -1))

Expand Down

0 comments on commit 1c407ec

Please sign in to comment.