28
28
(require 'lsp-semantic-tokens )
29
29
30
30
(defgroup lsp-ada nil
31
- " Settings for Ada Language Server."
32
- :group 'tools
33
- :tag " Language Server"
31
+ " Settings for Ada Language Server.
32
+
33
+ There is a hierarchy of configuration sources which are considered by
34
+ the Ada Language Server, including `lsp-mode' configuration settings,
35
+ external configuration files, as well as the server's own default
36
+ settings. When `lsp-mode' does not explicitly provide a value for a
37
+ setting (i.e., it is \\= 'Not Specified\\= '), its value will be
38
+ determined by one of the other configuration sources. Refer to the Ada
39
+ Language Server's Settings Documentation for specific details."
40
+ :group 'lsp-mode
41
+ :link `(url-link :tag " Settings Documentation"
42
+ ,(concat " https://github.com/AdaCore/ada_language_server"
43
+ " /blob/master/doc/settings.md" ))
44
+ :prefix " lsp-ada-"
34
45
:package-version '(lsp-mode . " 6.2" ))
35
46
36
47
(lsp-defcustom lsp-ada-project-file nil
@@ -57,25 +68,198 @@ environment."
57
68
;;;### autoload (put 'lsp-ada-project-file 'safe-local-variable 'stringp)
58
69
59
70
(lsp-defcustom lsp-ada-option-charset " UTF-8"
60
- " The charset to use by the Ada Language server. Defaults to \\= 'UTF-8\\= '."
61
- :type 'string
71
+ " The charset to use by the Ada Language server. Defaults to \\= 'UTF-8\\= '."
72
+ :type '(choice (string :tag " Charset" )
73
+ (const :tag " Not Specified" nil ))
62
74
:group 'lsp-ada
63
75
:package-version '(lsp-mode . " 6.2" )
64
76
:lsp-path " ada.defaultCharset" )
65
77
66
- (lsp-defcustom lsp-ada-enable-diagnostics t
67
- " A boolean to disable diagnostics. Defaults to true."
68
- :type 'boolean
78
+ (lsp-defcustom lsp-ada-display-method-ancestry-on-navigation nil
79
+ " Policy for displaying overriding/overridden subprograms on navigation requests."
80
+ :type '(choice (const " never" )
81
+ (const " usage_and_abstract_only" )
82
+ (const " definition_only" )
83
+ (const " always" )
84
+ (const :tag " Not Specified" nil ))
69
85
:group 'lsp-ada
70
- :package-version '(lsp-mode . " 6.2" )
86
+ :package-version '(lsp-mode . " 9.0.1" )
87
+ :lsp-path " ada.displayMethodAncestryOnNavigation" )
88
+
89
+ (lsp-defcustom lsp-ada-documentation-style nil
90
+ " Style used to extract documentation for an entity."
91
+ :type '(choice (const " gnat" )
92
+ (const " leading" )
93
+ (const :tag " Not Specified" nil ))
94
+ :group 'lsp-ada
95
+ :package-version '(lsp-mode . " 9.0.1" )
96
+ :lsp-path " ada.documentationStyle" )
97
+
98
+ (lsp-defcustom lsp-ada-enable-diagnostics nil
99
+ " Whether diagnostics are enabled."
100
+ :type '(choice (const :tag " Enabled" t )
101
+ (const :tag " Disabled" :json-false )
102
+ (const :tag " Not Specified" nil ))
103
+ :group 'lsp-ada
104
+ :package-version '(lsp-mode . " 9.0.1" )
71
105
:lsp-path " ada.enableDiagnostics" )
72
106
107
+ (lsp-defcustom lsp-ada-enable-indexing nil
108
+ " Whether the server indexes the source files after loading a project."
109
+ :type '(choice (const :tag " Enabled" t )
110
+ (const :tag " Disabled" :json-false )
111
+ (const :tag " Not Specified" nil ))
112
+ :group 'lsp-ada
113
+ :package-version '(lsp-mode . " 9.0.1" )
114
+ :lsp-path " ada.enableIndexing" )
115
+
116
+ (lsp-defcustom lsp-ada-fold-comments nil
117
+ " Whether the server sends information to control folding comment blocks."
118
+ :type '(choice (const :tag " Enabled" t )
119
+ (const :tag " Disabled" :json-false )
120
+ (const :tag " Not Specified" nil ))
121
+ :group 'lsp-ada
122
+ :package-version '(lsp-mode . " 9.0.1" )
123
+ :lsp-path " ada.foldComments" )
124
+
125
+ (lsp-defcustom lsp-ada-follow-symlinks nil
126
+ " Whether the server attempts to resolve symlinks for file names."
127
+ :type '(choice (const :tag " Enabled" t )
128
+ (const :tag " Disabled" :json-false )
129
+ (const :tag " Not Specified" nil ))
130
+ :group 'lsp-ada
131
+ :package-version '(lsp-mode . " 9.0.1" )
132
+ :lsp-path " ada.followSymlinks" )
133
+
134
+ (lsp-defcustom lsp-ada-insert-with-clauses nil
135
+ " Whether to automatically insert missing with-clauses for completions."
136
+ :type '(choice (const :tag " Enabled" t )
137
+ (const :tag " Disabled" :json-false )
138
+ (const :tag " Not Specified" nil ))
139
+ :group 'lsp-ada
140
+ :package-version '(lsp-mode . " 9.0.1" )
141
+ :lsp-path " ada.insertWithClauses" )
142
+
143
+ (lsp-defcustom lsp-ada-log-threshold nil
144
+ " Maximum number of preserved trace files in the ALS log directory."
145
+ :type '(choice (integer :tag " Threshold" )
146
+ (const :tag " Not Specified" nil ))
147
+ :group 'lsp-ada
148
+ :link `(url-link :tag " Traces Documentation"
149
+ ,(concat " https://github.com/AdaCore/ada_language_server"
150
+ " /blob/master/doc/traces.md" ))
151
+ :package-version '(lsp-mode . " 9.0.1" )
152
+ :lsp-path " ada.logThreshold" )
153
+
154
+ (lsp-defcustom lsp-ada-named-notation-threshold nil
155
+ " Number of parameters when named notation is used in completion snippets."
156
+ :type '(choice (integer :tag " Threshold" )
157
+ (const :tag " Not Specified" nil ))
158
+ :group 'lsp-ada
159
+ :package-version '(lsp-mode . " 9.0.1" )
160
+ :lsp-path " ada.namedNotationThreshold" )
161
+
162
+ (lsp-defcustom lsp-ada-on-type-formatting-indent-only nil
163
+ " Whether textDocument/onTypeFormatting request only indents a new line."
164
+ :type '(choice (const :tag " Enabled" t )
165
+ (const :tag " Disabled" :json-false )
166
+ (const :tag " Not Specified" nil ))
167
+ :group 'lsp-ada
168
+ :package-version '(lsp-mode . " 9.0.1" )
169
+ :lsp-path " ada.onTypeFormatting.indentOnly" )
170
+
171
+ (lsp-defcustom lsp-ada-project-diagnostics nil
172
+ " Whether the Ada Language Server should emit project diagnostics.
173
+
174
+ This setting is ignored if `lsp-ada-enable-diagnostics' is not enabled.
175
+ A workspace reload is necessary to refresh the diagnostics after
176
+ modifying this setting."
177
+ :type '(choice (const :tag " Enabled" t )
178
+ (const :tag " Disabled" :json-false )
179
+ (const :tag " Not Specified" nil ))
180
+ :group 'lsp-ada
181
+ :package-version '(lsp-mode . " 9.0.1" )
182
+ :lsp-path " ada.projectDiagnostics" )
183
+
184
+ (lsp-defcustom lsp-ada-relocate-build-tree nil
185
+ " Path to use for out-of-tree builds."
186
+ :type '(choice (string :tag " Path" )
187
+ (const :tag " Not Specified" nil ))
188
+ :group 'lsp-ada
189
+ :package-version '(lsp-mode . " 9.0.1" )
190
+ :lsp-path " ada.relocateBuildTree" )
191
+
192
+ (lsp-defcustom lsp-ada-root-dir nil
193
+ " The root directory for artifact relocation.
194
+
195
+ This setting must be used in conjunction with `lsp-ada-relocate-build-tree' ."
196
+ :type '(choice (string :tag " Root Dir" )
197
+ (const :tag " Not Specified" nil ))
198
+ :group 'lsp-ada
199
+ :package-version '(lsp-mode . " 9.0.1" )
200
+ :lsp-path " ada.rootDir" )
201
+
202
+ (lsp-defcustom lsp-ada-rename-in-comments nil
203
+ " Whether to apply textDocument/rename to comments."
204
+ :type '(choice (const :tag " Enabled" t )
205
+ (const :tag " Disabled" :json-false )
206
+ (const :tag " Not Specified" nil ))
207
+ :group 'lsp-ada
208
+ :package-version '(lsp-mode . " 9.0.1" )
209
+ :lsp-path " ada.renameInComments" )
210
+
211
+ (lsp-defcustom lsp-ada-scenario-variables nil
212
+ " Scenario variables for project."
213
+ :type '(alist :tag " Scenario Variable(s)"
214
+ :key-type (symbol :tag " Variable Name" )
215
+ :value-type (string :tag " Value" ))
216
+ :group 'lsp-ada
217
+ :package-version '(lsp-mode . " 9.0.1" )
218
+ :lsp-path " ada.scenarioVariables" )
219
+
220
+ (lsp-defcustom lsp-ada-use-completion-snippets nil
221
+ " Whether to enable snippets in completion results."
222
+ :type '(choice (const :tag " Enabled" t )
223
+ (const :tag " Disabled" :json-false )
224
+ (const :tag " Not Specified" nil ))
225
+ :group 'lsp-ada
226
+ :package-version '(lsp-mode . " 9.0.1" )
227
+ :lsp-path " ada.useCompletionSnippets" )
228
+
229
+ (lsp-defcustom lsp-ada-use-gnatformat nil
230
+ " Enables GNATformat as the formatting provider for Ada source files.
231
+
232
+ This option controls the formatting provider."
233
+ :type '(choice (const :tag " GNATformat" t )
234
+ (const :tag " GNATpp" :json-false )
235
+ (const :tag " Not Specified" nil ))
236
+ :group 'lsp-ada
237
+ :package-version '(lsp-mode . " 9.0.1" )
238
+ :lsp-path " ada.useGnatformat" )
239
+
73
240
(defcustom lsp-ada-als-executable " ada_language_server"
74
241
" Command to start the Ada language server."
75
242
:group 'lsp-ada
76
243
:risky t
77
244
:type 'file )
78
245
246
+ (defcustom lsp-ada-library-folders #'lsp-ada--default-library-folders
247
+ " List of Ada library folders.
248
+
249
+ Library folders contain source which may be visited from a workspace,
250
+ but whose source files are not themselves considered a separate
251
+ workspace. This typically applies to language run-time source file
252
+ folders.
253
+
254
+ Instead of a list of a folders, a function may be provided, which will
255
+ be called with the most recently active workspace as a parameter and
256
+ must return a list of Ada library folders, or nil if none."
257
+ :group 'lsp-ada
258
+ :type '(choice function
259
+ (repeat :tag " Library Folders"
260
+ (directory :tag " Library Folder" )))
261
+ :package-version '(lsp-mode . " 9.0.1" ))
262
+
79
263
(defcustom lsp-ada-semantic-token-face-overrides
80
264
'((" namespace" . default )
81
265
(" modifier" . lsp-face-semhl-keyword))
@@ -106,6 +290,7 @@ environment."
106
290
(defvar lsp-ada--als-downloaded-executable
107
291
(f-join lsp-server-install-dir
108
292
" ada-ls"
293
+ " integration" " vscode" " ada"
109
294
(symbol-name (lsp-resolve-value lsp--system-arch))
110
295
(pcase system-type
111
296
('gnu/linux " linux" )
@@ -122,28 +307,36 @@ environment."
122
307
(setq lsp-ada--als-download-url-cache
123
308
(lsp--find-latest-gh-release-url
124
309
" https://api.github.com/repos/AdaCore/ada_language_server/releases/latest"
125
- (format " %s .zip "
310
+ (format " %s .tar.gz "
126
311
(pcase (list system-type (lsp-resolve-value lsp--system-arch))
127
- ('(gnu/linux x64) " Linux_amd64 " )
128
- ('(gnu/linux arm64) " Linux_aarch64 " )
129
- ('(darwin x64) " macOS_amd64 " )
130
- ('(darwin arm64) " macOS_aarch64 " )
131
- ('(windows-nt x64) " Windows_amd64 " )
132
- (`(, _ x64) " Linux_amd64 " ))))))
312
+ ('(gnu/linux x64) " linux-x64 " )
313
+ ('(gnu/linux arm64) " linux-arm64 " )
314
+ ('(darwin x64) " darwin-x64 " )
315
+ ('(darwin arm64) " darwin-arm64 " )
316
+ ('(windows-nt x64) " win32-x64 " )
317
+ (`(, _ x64) " linux-x64 " ))))))
133
318
134
319
(defun lsp-ada--als-store-path ()
135
320
" Store Path for the downloaded Ada Language Server."
136
321
(f-join lsp-server-install-dir
137
322
" ada-ls"
138
- (file-name-base (or lsp-ada--als-download-url-cache
139
- (lsp-ada--als-latest-release-url)
140
- " ada-ls" ))))
323
+ (string-remove-suffix
324
+ " .tar.gz"
325
+ (file-name-nondirectory
326
+ (or lsp-ada--als-download-url-cache
327
+ (lsp-ada--als-latest-release-url)
328
+ " ada-ls" )))))
329
+
330
+ (defun lsp-ada--default-library-folders (_workspace )
331
+ " Determine the set of Ada library folders."
332
+ (when (string-match-p " /adainclude/" (buffer-file-name ))
333
+ (list (file-name-directory (buffer-file-name )))))
141
334
142
335
(lsp-dependency
143
336
'ada-ls
144
337
'(:download :url lsp-ada--als-latest-release-url
145
338
:store-path lsp-ada--als-store-path
146
- :decompress :zip
339
+ :decompress :targz
147
340
:binary-path lsp-ada--als-downloaded-executable
148
341
:set-executable? t )
149
342
'(:system lsp-ada-als-executable))
@@ -153,16 +346,23 @@ environment."
153
346
(lambda () (lsp-package-path 'ada-ls )))
154
347
:major-modes '(ada-mode ada-ts-mode)
155
348
:priority -1
349
+ :initialization-options (lambda ()
350
+ (ht-get (lsp-configuration-section " ada" ) " ada" ))
351
+ ; ; Send workspace/didChangeConfiguration as a workaround for:
352
+ ; ; https://github.com/AdaCore/ada_language_server/issues/1209
156
353
:initialized-fn (lambda (workspace )
157
354
(with-lsp-workspace workspace
158
- (lsp--set-configuration
159
- (lsp-configuration-section " ada" ))))
355
+ (lsp--set-configuration
356
+ (lsp-configuration-section " ada" ))))
357
+ :library-folders-fn (lambda (workspace )
358
+ (if (functionp lsp-ada-library-folders)
359
+ (funcall lsp-ada-library-folders workspace)
360
+ lsp-ada-library-folders))
160
361
:download-server-fn (lambda (_client callback error-callback _update? )
161
362
(lsp-package-ensure 'ada-ls callback error-callback))
162
363
:semantic-tokens-faces-overrides `( :types , lsp-ada-semantic-token-face-overrides
163
364
:modifiers , lsp-ada-semantic-token-modifier-face-overrides )
164
- :server-id 'ada-ls
165
- :synchronize-sections '(" ada" )))
365
+ :server-id 'ada-ls ))
166
366
167
367
(lsp-register-client
168
368
(make-lsp-client :new-connection (lsp-stdio-connection
0 commit comments