Skip to content

Commit 1c407ec

Browse files
authored
Autocompletion options for Nix (nixd) (#4593)
* Nix autocompletion options * Support for formatting with nixd * Revert nixd lsp name
1 parent 27d6e79 commit 1c407ec

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

clients/lsp-nix.el

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,57 @@
5454
:type 'string
5555
:package-version '(lsp-mode . "8.0.0"))
5656

57+
(lsp-defcustom lsp-nix-nixd-formatting-command nil
58+
"External formatter command with arguments.
59+
60+
Example: [ \"nixpkgs-fmt\" ]"
61+
:type 'lsp-string-vector
62+
:group 'lsp-nix-nixd
63+
:lsp-path "nixd.formatting.command"
64+
:package-version '(lsp-mode . "9.0.1"))
65+
66+
(lsp-defcustom lsp-nix-nixd-nixpkgs-expr nil
67+
"This expression will be interpreted as \"nixpkgs\" toplevel
68+
Nixd provides package, lib completion/information from it.
69+
70+
Resource Usage: Entries are lazily evaluated, entire nixpkgs takes 200~300MB
71+
for just \"names\". Package documentation, versions, are evaluated by-need.
72+
73+
Example: \"import <nixpkgs> { }\""
74+
:type 'string
75+
:group 'lsp-nix-nixd
76+
:lsp-path "nixd.nixpkgs.expr"
77+
:package-version '(lsp-mode . "9.0.1"))
78+
79+
(lsp-defcustom lsp-nix-nixd-nixos-options-expr nil
80+
"Option set for NixOS option completion. If this is omitted, the default
81+
search path (<nixpkgs>) will be used.
82+
83+
Example:
84+
\"(builtins.getFlake \"/home/lyc/flakes\").nixosConfigurations.adrastea.options\""
85+
:type 'string
86+
:group 'lsp-nix-nil
87+
:lsp-path "nixd.options.nixos.expr"
88+
:package-version '(lsp-mode . "9.0.1"))
89+
90+
(lsp-defcustom lsp-nix-nixd-home-manager-options-expr nil
91+
"Option set for home-manager option completion.
92+
93+
Example:
94+
\"(builtins.getFlake \"/home/lyc/flakes\").nixosConfigurations.adrastea.options\""
95+
:type 'string
96+
:group 'lsp-nix-nil
97+
:lsp-path "nixd.options.home-manager.expr"
98+
:package-version '(lsp-mode . "9.0.1"))
99+
57100
(lsp-register-client
58101
(make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-nix-nixd-server-path))
59102
:major-modes '(nix-mode nix-ts-mode)
103+
:initialized-fn (lambda (workspace)
104+
(with-lsp-workspace workspace
105+
(lsp--set-configuration
106+
(lsp-configuration-section "nixd"))))
107+
:synchronize-sections '("nixd")
60108
:server-id 'nixd-lsp
61109
:priority -1))
62110

0 commit comments

Comments
 (0)