@@ -39,6 +39,197 @@ executable with variable `exec-path'."
39
39
:group 'lsp-zig
40
40
:type 'string )
41
41
42
+ (defcustom lsp-zig-trace-server " off"
43
+ " Traces the communication between Emacs and the language server."
44
+ :group 'lsp-zig
45
+ :type '(choice (const " off" )
46
+ (const " messages" )
47
+ (const " verbose" )))
48
+
49
+ (defcustom lsp-zig-check-for-update t
50
+ " Whether to automatically check for new updates."
51
+ :group 'lsp-zig
52
+ :type 'boolean )
53
+
54
+ (defcustom lsp-zig-zls-enable-snippets t
55
+ " Enables snippet completions when the client also supports them."
56
+ :group 'lsp-zig
57
+ :type 'boolean )
58
+
59
+ (defcustom lsp-zig-zls-enable-argument-placeholders t
60
+ " Whether to enable function argument placeholder completions."
61
+ :group 'lsp-zig
62
+ :type 'boolean )
63
+
64
+ (defcustom lsp-zig-zls-enable-build-on-save nil
65
+ " Whether to enable build-on-save diagnostics."
66
+ :group 'lsp-zig
67
+ :type 'boolean )
68
+
69
+ (defcustom lsp-zig-zls-build-on-save-step " install"
70
+ " Select which step should be executed on build-on-save."
71
+ :group 'lsp-zig
72
+ :type 'string )
73
+
74
+ (defcustom lsp-zig-zls-enable-autofix nil
75
+ " Whether to automatically fix errors on save.
76
+ Currently supports adding and removing discards."
77
+ :group 'lsp-zig
78
+ :type 'boolean )
79
+
80
+ (defcustom lsp-zig-zls-semantic-tokens " partial"
81
+ " Traces the communication between Emacs and the language server."
82
+ :group 'lsp-zig
83
+ :type '(choice (const " off" )
84
+ (const " messages" )
85
+ (const " verbose" )))
86
+
87
+ (defcustom lsp-zig-zls-enable-inlay-hints t
88
+ " Enables inlay hint support when the client also supports it."
89
+ :group 'lsp-zig
90
+ :type 'boolean )
91
+
92
+ (defcustom lsp-zig-zls-inlay-hints-show-variable-type-hints t
93
+ " Enable inlay hints for variable type."
94
+ :group 'lsp-zig
95
+ :type 'boolean )
96
+
97
+ (defcustom lsp-zig-zls-inlay-hints-show-parameter-name t
98
+ " Enable inlay hints for parameter names."
99
+ :group 'lsp-zig
100
+ :type 'boolean )
101
+
102
+ (defcustom lsp-zig-zls-inlay-hints-exclude-single-argument t
103
+ " Don't show inlay hints for single argument calls."
104
+ :group 'lsp-zig
105
+ :type 'boolean )
106
+
107
+ (defcustom lsp-zig-zls-inlay-hints-show-builtin t
108
+ " Don't show inlay hints for single argument calls."
109
+ :group 'lsp-zig
110
+ :type 'boolean )
111
+
112
+ (defcustom lsp-zig-zls-inlay-hints-hide-redundant-param-names nil
113
+ " Hides inlay hints when parameter name matches the identifier (e.g. foo: foo)."
114
+ :group 'lsp-zig
115
+ :type 'boolean )
116
+
117
+ (defcustom lsp-zig-zls-inlay-hints-hide-redundant-param-names-last-token nil
118
+ " Hides inlay hints when parameter name matches the last token of a parameter
119
+ node (e.g. foo: bar.foo, foo: &foo)."
120
+ :group 'lsp-zig
121
+ :type 'boolean )
122
+
123
+ (defcustom lsp-zig-zls-warn-style nil
124
+ " Enables warnings for style guideline mismatches."
125
+ :group 'lsp-zig
126
+ :type 'boolean )
127
+
128
+ (defcustom lsp-zig-zls-highlight-global-var-declarations nil
129
+ " Whether to highlight global var declarations."
130
+ :group 'lsp-zig
131
+ :type 'boolean )
132
+
133
+ (defcustom lsp-zig-zls-dangerous-comptime-experiments-do-not-enable nil
134
+ " When true, skips searching for references in std.
135
+ Improves lookup speed for functions in user's code. Renaming and
136
+ go-to-definition will continue to work as is."
137
+ :group 'lsp-zig
138
+ :type 'boolean )
139
+
140
+ (defcustom lsp-zig-zls-skip-std-references nil
141
+ " hen true, skips searching for references in std.
142
+ Improves lookup speed for functions in user's code. Renaming and
143
+ go-to-definition will continue to work as is."
144
+ :group 'lsp-zig
145
+ :type 'boolean )
146
+
147
+ (defcustom lsp-zig-zls-prefer-ast-check-as-child-process t
148
+ " Favor using `zig ast-check` instead of ZLS's fork."
149
+ :group 'lsp-zig
150
+ :type 'boolean )
151
+
152
+ (defcustom lsp-zig-zls-record-session nil
153
+ " When true, zls will record all request is receives and write in into
154
+ `record_session_path`, so that they can replayed with `zls replay`."
155
+ :group 'lsp-zig
156
+ :type 'boolean )
157
+
158
+ (defcustom lsp-zig-zls-record-session-path " "
159
+ " Output file path when `record_session` is set.
160
+ The recommended file extension *.zlsreplay."
161
+ :group 'lsp-zig
162
+ :type 'string )
163
+
164
+ (defcustom lsp-zig-zls-replay-session-path " "
165
+ " Used when calling `zls replay` for specifying the replay file.
166
+ If no extra argument is given `record_session_path` is used as the default path."
167
+ :group 'lsp-zig
168
+ :type 'string )
169
+
170
+ (defcustom lsp-zig-zls-builtin-path " "
171
+ " Path to `builtin' ; useful for debugging, automatically set if let null."
172
+ :group 'lsp-zig
173
+ :type 'string )
174
+
175
+ (defcustom lsp-zig-zls-zig-lib-path " "
176
+ " Zig library path.
177
+ e.g. `/path/to/zig/lib/zig`, used to analyze std library imports."
178
+ :group 'lsp-zig
179
+ :type 'string )
180
+
181
+ (defcustom lsp-zig-zls-build-runner-path " "
182
+ " Path to the `build_runner.zig` file provided by zls.
183
+ null is equivalent to `${executable_directory}/build_runner.zig`."
184
+ :group 'lsp-zig
185
+ :type 'string )
186
+
187
+ (defcustom lsp-zig-zls-global-cache-path " "
188
+ " Path to a directory that will be used as zig's cache.
189
+ null is equivalent to `${KnownFolders.Cache}/zls`."
190
+ :group 'lsp-zig
191
+ :type 'string )
192
+
193
+ (defcustom lsp-zig-zls-build-runner-global-cache-path " "
194
+ " Path to a directory that will be used as the global cache path when executing
195
+ a projects build.zig. null is equivalent to the path shown by `zig env`."
196
+ :group 'lsp-zig
197
+ :type 'string )
198
+
199
+ (defcustom lsp-zig-zls-completions-with-replace nil
200
+ " Completions confirm behavior.
201
+ If `true' , replace the text after the cursor."
202
+ :group 'lsp-zig
203
+ :type 'boolean )
204
+
205
+ (defcustom lsp-zig-zls-completion-label-details nil
206
+ " When false, the function signature of completion results is hidden.
207
+ Improves readability in some editors."
208
+ :group 'lsp-zig
209
+ :type 'boolean )
210
+
211
+ ; ;
212
+ ; ;; Util
213
+
214
+ (defmacro lsp-zig--mute-apply (&rest body )
215
+ " Execute BODY without message."
216
+ (declare (indent 0 ) (debug t ))
217
+ `(let (message-log-max )
218
+ (with-temp-message (or (current-message ) nil )
219
+ (let ((inhibit-message t )) ,@body ))))
220
+
221
+ (defun lsp-zig--execute (cmd &rest args )
222
+ " Return non-nil if CMD executed succesfully with ARGS."
223
+ (save-window-excursion
224
+ (lsp-zig--mute-apply
225
+ (= 0 (shell-command (concat cmd " "
226
+ (mapconcat #'shell-quote-argument
227
+ (cl-remove-if #'null args)
228
+ " " )))))))
229
+
230
+ ; ;
231
+ ; ;; Installation
232
+
42
233
(defcustom lsp-zig-server-store-path
43
234
(expand-file-name " zig/" lsp-server-install-dir)
44
235
" The path to the file in which zls will be stored."
@@ -75,28 +266,6 @@ executable with variable `exec-path'."
75
266
(defvar lsp-zig--downloaded-file (f-join lsp-zig-server-store-path " temp.tar" )
76
267
" The full file path after downloading the server zipped file." )
77
268
78
- ; ;
79
- ; ;; Util
80
-
81
- (defmacro lsp-zig--mute-apply (&rest body )
82
- " Execute BODY without message."
83
- (declare (indent 0 ) (debug t ))
84
- `(let (message-log-max )
85
- (with-temp-message (or (current-message ) nil )
86
- (let ((inhibit-message t )) ,@body ))))
87
-
88
- (defun lsp-zig--execute (cmd &rest args )
89
- " Return non-nil if CMD executed succesfully with ARGS."
90
- (save-window-excursion
91
- (lsp-zig--mute-apply
92
- (= 0 (shell-command (concat cmd " "
93
- (mapconcat #'shell-quote-argument
94
- (cl-remove-if #'null args)
95
- " " )))))))
96
-
97
- ; ;
98
- ; ;; Installation
99
-
100
269
(defun lsp-zig--stored-zls-executable ()
101
270
" Return the stored zls executable.
102
271
@@ -124,6 +293,39 @@ and not the global storage."
124
293
; ;
125
294
; ;; Core
126
295
296
+ (lsp-register-custom-settings
297
+ '((" zig.zls.trace.server" lsp-zig-trace-server)
298
+ (" zig.zls.checkForUpdate" lsp-zig-check-for-update)
299
+ (" zig.zls.path" lsp-zig-zls-executable)
300
+ (" zig.zls.enableSnippets" lsp-zig-zls-enable-snippets)
301
+ (" zig.zls.enableArgumentPlaceholders" lsp-zig-zls-enable-argument-placeholders)
302
+ (" zig.zls.enableBuildOnSave" lsp-zig-zls-enable-build-on-save)
303
+ (" zig.zls.buildOnSaveStep" lsp-zig-zls-build-on-save-step)
304
+ (" zig.zls.enableAutofix" lsp-zig-zls-enable-autofix)
305
+ (" zig.zls.semanticTokens" lsp-zig-zls-semantic-tokens)
306
+ (" zig.zls.enableInlayHints" lsp-zig-zls-enable-inlay-hints)
307
+ (" zig.zls.inlayHintsShowVariableTypeHints" lsp-zig-zls-inlay-hints-show-variable-type-hints)
308
+ (" zig.zls.inlayHintsShowParameterName" lsp-zig-zls-inlay-hints-show-parameter-name)
309
+ (" zig.zls.inlayHintsShowBuiltin" lsp-zig-zls-inlay-hints-show-builtin)
310
+ (" zig.zls.inlayHintsExcludeSingleArgument" lsp-zig-zls-inlay-hints-exclude-single-argument)
311
+ (" zig.zls.inlayHintsHideRedundantParamNames" lsp-zig-zls-inlay-hints-hide-redundant-param-names)
312
+ (" zig.zls.inlayHintsHideRedundantParamNamesLastToken" lsp-zig-zls-inlay-hints-hide-redundant-param-names-last-token)
313
+ (" zig.zls.warnStyle" lsp-zig-zls-warn-style)
314
+ (" zig.zls.highlightGlobalVarDeclarations" lsp-zig-zls-highlight-global-var-declarations)
315
+ (" zig.zls.dangerousComptimeExperimentsDoNotEnable" lsp-zig-zls-dangerous-comptime-experiments-do-not-enable)
316
+ (" zig.zls.skipStdReferences" lsp-zig-zls-skip-std-references)
317
+ (" zig.zls.preferAstCheckAsChildProcess" lsp-zig-zls-prefer-ast-check-as-child-process)
318
+ (" zig.zls.recordSession" lsp-zig-zls-record-session)
319
+ (" zig.zls.recordSessionPath" lsp-zig-zls-record-session-path)
320
+ (" zig.zls.replaySessionPath" lsp-zig-zls-replay-session-path)
321
+ (" zig.zls.builtinPath" lsp-zig-zls-builtin-path)
322
+ (" zig.zls.zigLibPath" lsp-zig-zls-zig-lib-path)
323
+ (" zig.zls.buildRunnerPath" lsp-zig-zls-build-runner-path)
324
+ (" zig.zls.globalCachePath" lsp-zig-zls-global-cache-path)
325
+ (" zig.zls.buildRunnerGlobalCachePath" lsp-zig-zls-build-runner-global-cache-path)
326
+ (" zig.zls.completionsWithReplace" lsp-zig-zls-completions-with-replace)
327
+ (" zig.zls.completionLabelDetails" lsp-zig-zls-completion-label-details)))
328
+
127
329
(lsp-register-client
128
330
(make-lsp-client
129
331
:new-connection (lsp-stdio-connection
0 commit comments