-
-
Notifications
You must be signed in to change notification settings - Fork 900
/
Copy pathlsp-nix.el
170 lines (137 loc) · 5.57 KB
/
lsp-nix.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
;;; lsp-nix.el --- lsp-mode nix integration -*- lexical-binding: t; -*-
;; Copyright (C) 2020 lsp-mode maintainers
;; Author: Seong Yong-ju <[email protected]>
;; Keywords: languages
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Client for the rnix language server.
;;; Code:
(require 'lsp-mode)
(defgroup lsp-nix-rnix nil
"LSP support for Nix, using rnix-lsp."
:group 'lsp-mode
:link '(url-link "https://github.com/nix-community/rnix-lsp"))
(defcustom lsp-nix-rnix-server-path "rnix-lsp"
"Executable path for the server."
:group 'lsp-nix-rnix
:type 'string
:package-version '(lsp-mode . "8.0.0"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-nix-rnix-server-path))
:major-modes '(nix-mode nix-ts-mode)
:server-id 'rnix-lsp
:priority -2))
(defgroup lsp-nix-nixd nil
"LSP support for Nix, using nixd language server."
:group 'lsp-mode
:link '(url-link "https://github.com/nix-community/nixd"))
(defcustom lsp-nix-nixd-server-path "nixd"
"Executable path for the server."
:group 'lsp-nix-nixd
: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/nb/nix\").nixosConfigurations.mnd.options\"`"
:type 'string
:group 'lsp-nix-nixd
: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/nb/nix\").homeConfigurations.\"nb@mnd\".options\"`"
:type 'string
:group 'lsp-nix-nixd
: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))
(defgroup lsp-nix-nil nil
"LSP support for Nix, using nil."
:group 'lsp-mode
:link '(url-link "https://github.com/oxalica/nil"))
(defcustom lsp-nix-nil-server-path "nil"
"Executable path for the server."
:group 'lsp-nix-nil
:type 'string
:package-version '(lsp-mode . "9.0.0"))
(lsp-defcustom lsp-nix-nil-formatter nil
"External formatter command with arguments.
Example [nixpkgs-fmt]."
:type 'lsp-string-vector
:group 'lsp-nix-nil
:lsp-path "nil.formatting.command"
:package-version '(lsp-mode . "9.0.0"))
(lsp-defcustom lsp-nix-nil-ignored-diagnostics nil
"Ignored diagnostic kinds."
:type 'lsp-string-vector
:group 'lsp-nix-nil
:lsp-path "nil.diagnostics.ignored"
:package-version '(lsp-mode . "9.0.0"))
(lsp-defcustom lsp-nix-nil-exclude-files-diagnostic nil
"Files to exclude from showing diagnostics."
:type 'lsp-string-vector
:group 'lsp-nix-nil
:lsp-path "nil.diagnostics.excludedFiles"
:package-version '(lsp-mode . "9.0.0"))
(lsp-defcustom lsp-nix-nil-max-mem 10000
"Max Memory MB"
:type 'number
:group 'lsp-nix-nil
:lsp-path "nil.nix.maxMemoryMB"
:package-version '(lsp-mode . "9.0.0"))
(lsp-defcustom lsp-nix-nil-auto-eval-inputs t
"Auto Eval Inputs"
:type 'boolean
:group 'lsp-nix-nil
:lsp-path "nil.nix.flake.autoEvalInputs"
:package-version '(lsp-mode . "9.0.0"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-nix-nil-server-path))
:major-modes '(nix-mode nix-ts-mode)
:initialized-fn (lambda (workspace)
(with-lsp-workspace workspace
(lsp--set-configuration
(lsp-configuration-section "nil"))))
:synchronize-sections '("nil")
:server-id 'nix-nil))
(lsp-consistency-check lsp-nix)
(provide 'lsp-nix)
;;; lsp-nix.el ends here