Skip to content

Commit bd5707c

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 7996f57 + 55143d9 commit bd5707c

24 files changed

+860
-485
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ section below it for the last release. -->
1414
* Fix Goto Definition for entry in Protected Types
1515
* Avoid `PRECONDITION_FAILURE` on editing an empty file
1616
* Avoid occurrences of `STALE_REFERENCE_ERROR` in Libadalang
17+
* Restore the usage of `initializationOptions` from the `initialize` request to
18+
receive initial settings
1719

1820
## 25.0.20241014
1921

doc/settings.md

Lines changed: 69 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,80 @@
11
# Ada Language Server configuration
22

3-
The ALS reads initial configuration from the `initializationOptions`
4-
property of the `initialize` request (if any) and then updates
5-
the configuration with each `workspace/didChangeConfiguration`
6-
notification.
3+
## Configuration Sources
74

8-
In the context of Visual Studio Code, configuration settings can be set in the
9-
workspace `settings.json` file or the [multi-root workspace
10-
file](https://code.visualstudio.com/docs/editor/multi-root-workspaces) by
11-
prefixing each setting name with `ada.`, e.g.
5+
The ALS can be given configuration settings in the following ways:
6+
7+
1. The `--config CONFIG_FILE` command line option, if specified.
8+
9+
2. The `initializationOptions` property of the `initialize` request, if specified.
10+
11+
3. In `workspace/didChangeConfiguration` LSP notifications.
12+
13+
4. In the User, Remote or Workspace settings of Visual Studio Code, where each setting name is prefixed with `ada.`.
14+
15+
If given, the configuration file must be a JSON file with the following structure:
1216

1317
```json
1418
{
15-
"ada.projectFile": "right_project.gpr",
16-
"ada.scenarioVariables": {
17-
"LIBRARY_TYPE": "static"
18-
},
19-
"ada.onTypeFormatting.indentOnly": true,
20-
"useGnatformat": true
19+
"projectFile": "...",
20+
"scenarioVariables": { ... },
21+
...
2122
}
2223
```
2324

24-
At the protocol level, any setting in `workspace/didChangeConfiguration` should
25-
be inside an `ada` JSON object, while there is no such wrapping object
26-
for `initializationOptions`. On the protocol level messages look like:
25+
If specified in the `initialize` request, settings should be wrapped into an `ada` JSON object in the `initializationOptions` property as follows:
2726

2827
```json
2928
{
3029
"jsonrpc": "2.0",
31-
"id": 123,
3230
"method": "initialize",
3331
"params": {
3432
"initializationOptions": {
35-
"projectFile": "right_project.gpr"
33+
"ada": {
34+
"projectFile": "right_project.gpr",
35+
"scenarioVariables": { ... },
36+
...
37+
}
3638
},
3739
...
3840
}
3941
}
42+
```
4043

44+
Similarly, settings passed in `workspace/didChangeConfiguration` notifications should also be wrapped into an `ada` JSON object:
45+
46+
```json
4147
{
4248
"jsonrpc": "2.0",
43-
"method": "workspace/didChangeConfiguration",
44-
"params": {
45-
"settings": {
46-
"ada": {
47-
"projectFile": "right_project.gpr"
48-
}
49-
}
49+
"method": "workspace/didChangeConfiguration",
50+
"params": {
51+
"settings": {
52+
"ada": {
53+
"projectFile": "right_project.gpr"
54+
}
55+
}
5056
}
5157
}
5258
```
5359

60+
In the context of Visual Studio Code, configuration settings can be set in the
61+
User, Remote or Workspace `settings.json` file or the [multi-root workspace
62+
file](https://code.visualstudio.com/docs/editor/multi-root-workspaces) by
63+
prefixing each setting name with `ada.`, e.g.
64+
65+
```json
66+
{
67+
"ada.projectFile": "right_project.gpr",
68+
"ada.scenarioVariables": {
69+
"LIBRARY_TYPE": "static"
70+
},
71+
"ada.onTypeFormatting.indentOnly": true,
72+
"ada.useGnatformat": true
73+
}
74+
```
75+
76+
## Settings
77+
5478
Ada Language Server understands these settings:
5579

5680
* [projectFile](#projectfile)
@@ -73,7 +97,7 @@ Ada Language Server understands these settings:
7397

7498
----
7599

76-
## projectFile
100+
### projectFile
77101

78102
You can configure the GNAT Project File via the `projectFile` key.
79103
The setting has a string value, that points to the `.gpr` file.
@@ -86,7 +110,7 @@ root folder, then ALS will use it.
86110
'projectFile': 'gnat/lsp_server.gpr'
87111
```
88112

89-
## scenarioVariables
113+
### scenarioVariables
90114

91115
You can configure scenario variables via the `scenarioVariables` key.
92116
The setting has an object value. Keys in this object correspond to
@@ -98,7 +122,7 @@ scenario variables names and string values to variables values.
98122
}
99123
```
100124

101-
## defaultCharset
125+
### defaultCharset
102126

103127
You can set the character set to use when the server has to use when reading
104128
files from disk by specifying an `defaultCharset` key. The default is
@@ -108,7 +132,7 @@ files from disk by specifying an `defaultCharset` key. The default is
108132
'defaultCharset': 'UTF-8'
109133
```
110134

111-
## relocateBuildTree
135+
### relocateBuildTree
112136

113137
With this option it is possible to achieve out-of-tree build. That is,
114138
real object, library or exec directories are relocated to the current
@@ -121,7 +145,7 @@ for more details about the corresponding gprbuild switch.
121145
'relocateBuildTree': '/home/user/project/build/'
122146
```
123147

124-
## rootDir
148+
### rootDir
125149

126150
This option is to be used with relocateBuildTree above and cannot be
127151
specified alone. This option specifies the root directory for artifacts
@@ -134,7 +158,7 @@ for more details about the corresponding gprbuild switch.
134158
'relocateBuildTree': '/home/user/project/'
135159
```
136160

137-
## enableDiagnostics
161+
### enableDiagnostics
138162

139163
You can explicitly deactivate the emission of diagnostics, via the
140164
`enableDiagnostics` key. By default, diagnostics are enabled.
@@ -144,7 +168,7 @@ The value is a boolean.
144168
'enableDiagnostics': false
145169
```
146170

147-
## projectDiagnostics
171+
### projectDiagnostics
148172

149173
This setting needs `enableDiagnostics` enabled and can be disabled to remove
150174
project related diagnotics.
@@ -154,7 +178,7 @@ The value is a boolean.
154178
'enableDiagnostics': false
155179
```
156180

157-
## enableIndexing
181+
### enableIndexing
158182

159183
By default, the server indexes the source files after loading a project,
160184
to speed up subsequent requests. This behavior can be controlled
@@ -165,7 +189,7 @@ The value is a boolean.
165189
'enableIndexing': false
166190
```
167191

168-
## renameInComments
192+
### renameInComments
169193

170194
The language server is able to edit Ada comments while executing
171195
`textDocument/rename` request. To enable this just set
@@ -176,7 +200,7 @@ The value is a boolean.
176200
'renameInComments': false
177201
```
178202

179-
## useCompletionSnippets
203+
### useCompletionSnippets
180204

181205
Whether we should use snippets in completion results. Snippets can be
182206
returned in case of subprogram calls for instance, with placeholders
@@ -187,7 +211,7 @@ The value is a boolean.
187211
'useCompletionSnippets': true
188212
```
189213

190-
## insertWithClauses
214+
### insertWithClauses
191215

192216
Whether we should automatically insert missing with-clauses when
193217
accepting completion for invisible symbols.
@@ -196,7 +220,7 @@ accepting completion for invisible symbols.
196220
'insertWithClauses': true
197221
```
198222

199-
## displayMethodAncestryOnNavigation
223+
### displayMethodAncestryOnNavigation
200224

201225
This setting controls the policy for displaying overriding and overridden
202226
subprograms on navigation requests such as `textDocument/definition`,
@@ -216,7 +240,7 @@ The different policies are:
216240
'displayMethodAncestryOnNavigation': 'always'
217241
```
218242

219-
## namedNotationThreshold
243+
### namedNotationThreshold
220244

221245
This setting defines the number of parameters/components at which point named
222246
notation is used for subprogram/aggregate completion snippets.
@@ -226,7 +250,7 @@ The value is a number. The default value is `3`.
226250
'namedNotationThreshold': 2
227251
```
228252

229-
## foldComments
253+
### foldComments
230254

231255
When this setting is `true` the server sends blocks information for comments which can be used for folding comment blocks.
232256
The value is a boolean. The default is `true`.
@@ -235,7 +259,7 @@ The value is a boolean. The default is `true`.
235259
'foldComments': false
236260
```
237261

238-
## followSymlinks
262+
### followSymlinks
239263

240264
When this setting is `false` the server doesn't do any attempts to normalize file names sent by a client.
241265
This means that symlinks stay unresolved and character case is unchanged (on case insensitive file systems).
@@ -246,7 +270,7 @@ The value is a boolean. The default is `true`.
246270
'followSymlinks': false
247271
```
248272

249-
## documentationStyle
273+
### documentationStyle
250274

251275
The language server supports different styles to document entities in the source
252276
code. This setting controls primary documentation style of entities. When
@@ -267,7 +291,7 @@ For more information about documentation styles see GNATdoc User's Manual.
267291
'documentationStyle': 'gnat'
268292
```
269293

270-
## trace.server
294+
### trace.server
271295

272296
This option controls the tracing of the communication between VS Code and the Ada
273297
language server. It causes the client to trace each message sent and received
@@ -283,13 +307,13 @@ On the server side this option does not trigger any additional logging.
283307

284308
An equivalent setting `gpr.trace.server` exists for tracing the communcation between VS Code and the GPR language server.
285309

286-
## onTypeFormatting.indentOnly
310+
### onTypeFormatting.indentOnly
287311

288312
This option controls if the `textDocument/onTypeFormatting` request only indents a new line, or if
289313
it additionally tries to format the previous node. By default, this option is enabled, that is,
290314
`textDocument/onTypeFormatting` only indents new lines.
291315

292-
## useGnatformat
316+
### useGnatformat
293317

294318
This option controls the formatting provider for the `textDocument/formatting`,
295319
`textDocument/rangeFormatting` and `textDocument/onTypeFormatting` request. By default, this option

doc/traces.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# ALS Trace File
1+
# ALS Traces
22

3-
Default traces file names are:
3+
## Traces Configuration Files
4+
5+
Default traces configuration file names are:
46

57
* For versions **< 24.0.6**:
68

7-
You will need to create a traces file manually under `$HOME/.als/traces.cfg`. You can
9+
You will need to create a traces configuration file manually under `$HOME/.als/traces.cfg`. You can
810
use the following contents as a starter:
911

1012
```text
@@ -19,8 +21,7 @@ Default traces file names are:
1921

2022
* For the **24.0.6** version:
2123

22-
Default traces file name is `$HOME/.als/traces.cfg`. This file gets automatically created
23-
if not present on the disk.
24+
Default traces configuration file name is `$HOME/.als/traces.cfg`. This file gets automatically created if not present on the disk.
2425

2526
* For versions **> 24.0.6**:
2627
1. `$HOME/.als/ada_ls_traces.cfg` for the language server spawned for Ada code, which produce `ada_ls_log.<timestamp>.log` log files by default.
@@ -30,40 +31,53 @@ Default traces file names are:
3031

3132
The first line of the traces files defines the traces output stream (a filename in our case) and the other lines are used to enable or disable traces.
3233

33-
Note that you can provide another traces file via the `--tracefile=<FILE>` command line option.
34+
Note that you can provide another traces configuration file via the `--tracefile=<FILE>` command line option.
35+
36+
## Supported Traces
3437

3538
Here is a list of the most useful supported traces:
3639

37-
## `ALS.IN` (default no)
40+
### `ALS.IN` (default: no)
41+
3842
Shows all the server's input. Use this way:
3943

4044
ALS.IN=yes
4145

42-
## `ALS.OUT` (default no)
46+
### `ALS.OUT` (default: no)
47+
4348
Shows all the server's output. Use this way:
4449

4550
ALS.OUT=yes
4651

47-
## `ALS.MAIN` (default yes)
52+
### `ALS.MAIN` (default: yes)
53+
4854
Trace requests, notifications and responses in ALS log files. Will
4955
also log any exception that occurs when handling LSP requests.
5056

5157
ALS.MAIN=yes
5258

53-
## `ALS.ALLOW_INCREMENTAL_TEXT_CHANGES` (default yes)
59+
### `ALS.ALLOW_INCREMENTAL_TEXT_CHANGES` (default: yes)
60+
5461
Request incremental (if `yes`) or full content (if `no`)
5562
[text document syncronization](https://microsoft.github.io/language-server-protocol/specification#textDocument_synchronization)
5663
in `initialize` response.
5764

5865
ALS.ALLOW_INCREMENTAL_TEXT_CHANGES=no
5966

60-
## `ALS.LAL_PP_OUTPUT_ON_FORMATTING` (default no)
67+
### `ALS.LAL_PP_OUTPUT_ON_FORMATTING` (default: no)
68+
6169
Log lalpp output if `yes`.
6270

6371
ALS.LAL_PP_OUTPUT_ON_FORMATTING=yes
6472

65-
## `ALS.GNATFORMAT` (default no)
73+
### `ALS.GNATFORMAT` (default: no)
6674

6775
Use GNATformat as format provider.
6876

6977
ALS.GNATFORMAT=yes
78+
79+
## Troubleshooting
80+
81+
If the traces configuration file can't get parsed after customizing it (e.g: because it contains syntax errors), the Ada Language Server will use its own default traces configuration and log files will be produced in the directory from where the Ada Language Server is launched (i.e: the workspace's root directory in VS Code).
82+
83+
VS Code users can use the `Ada: Open Ada Language Server Log File` command to quickly open the fallback log file in order understand why the Ada Language Server failed to parse the user's traces configuration file.

integration/vscode/ada/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ The Ada & SPARK tools are available to the community through different channels:
5656
* [ALIRE](https://alire.ada.dev/): The Ada LIbrary Repository provides the means to install compiler [toolchains](https://alire.ada.dev/docs/#toolchain-management).
5757
The `gnatprove` crate provides GNATprove.
5858
Both tools are available for Linux, Windows and macOS.
59-
* On Linux distributions you can use your package manager to install [GCC](https://gcc.gnu.org/) which includes the GNAT Ada compiler.
60-
You also need to install the `gprbuild` package.
6159
* On Windows with [msys2](https://www.msys2.org/) you can install the `gcc` and `gprbuild` packages.
6260
* On macOS you can find GCC releases including GNAT for Intel and Apple silicon at [this project on GitHub](https://github.com/simonjwright/distributing-gcc/releases) courtesy of Simon Wright.
6361

integration/vscode/ada/src/clients.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export function createClient(
8989
// Notify the server about file changes to Ada files contain in the workspace
9090
fileEvents: vscode.workspace.createFileSystemWatcher(pattern),
9191
},
92+
// Include the ada.* settings in the initialize request sent to the server
93+
initializationOptions: () => ({ ada: vscode.workspace.getConfiguration('ada') }),
9294
};
9395
// Create the language client
9496
return new LanguageClient(id, name, serverOptions, clientOptions);

0 commit comments

Comments
 (0)