Skip to content

Commit 816dc77

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 5848fd0 + ccde5ff commit 816dc77

File tree

141 files changed

+1051
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+1051
-122
lines changed

.vscode/settings.json.tmpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
"[ada]": {
1616
"editor.autoIndent": "none",
1717
"editor.formatOnType": true,
18-
"editor.tabSize": 3,
19-
"editor.detectIndentation": false,
2018
"showNotificationsOnErrors": true
2119
},
2220
"python.analysis.extraPaths": ["testsuite"],

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ section below it for the last release. -->
55
## \<next>
66

77
* Add a setting `ada.showNotificationsOnErrors` to control whether VS Code should display error notifications for failing LSP requests.
8+
* Add support for a default `.als.json` workspace configuration file and a global `$XDG_CONFIG_HOME/als/config.json` user configuration file. See [settings.md](https://github.com/AdaCore/ada_language_server/blob/master/doc/settings.md) for more information.
89

910
## 26.0.202411173
1011

doc/settings.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22

33
## Configuration Sources
44

5-
The ALS can be given configuration settings in the following ways:
5+
The ALS loads configuration settings from different sources. All configuration sources are loaded in the following order:
66

7-
1. The `--config CONFIG_FILE` command line option, if specified.
7+
1. A global user configuration file `$XDG_CONFIG_HOME/als/config.json`, if it exists.
88

9-
2. The `initializationOptions` property of the `initialize` request, if specified.
9+
1. A workspace-specific `.als.json` file in the directory where ALS is spawned, if it exists.
1010

11-
3. In `workspace/didChangeConfiguration` LSP notifications.
11+
This is the prefered location to store project-specific settings that are tracked in version control and shared among developers.
1212

13-
4. In the User, Remote or Workspace settings of Visual Studio Code, where each setting name is prefixed with `ada.`.
13+
1. The `--config CONFIG_FILE` file, if specified in the command line.
1414

15-
If given, the configuration file must be a JSON file with the following structure:
15+
1. The `initializationOptions` property of the `initialize` request, if specified.
16+
17+
1. In `workspace/didChangeConfiguration` LSP notifications, if specified.
18+
19+
Each configuration source can contain a partial list of settings. Thus each
20+
configuration source can override individual settings while preserving
21+
previously loaded settings.
22+
23+
Configuration files must be JSON files matching [this JSON schema](integration/vscode/ada/schemas/als-settings-schema.json). Roughly the structure looks like this:
1624

1725
```json
1826
{
@@ -57,6 +65,14 @@ Similarly, settings passed in `workspace/didChangeConfiguration` notifications s
5765
}
5866
```
5967

68+
## Base Configuration
69+
70+
The *base configuration* is the one that ALS reaches after loading configuration files (i.e. global user configuration, workspace-specific `.als.json` file, and `--config` command line argument).
71+
72+
After that the ALS may receive configuration changes through the `initialize` request, or the `workspace/didChangeConfiguration` notification. In those messages, if settings have the value `null`, ALS reverts their value to the base configuration. This allows clients to temporarily override settings, and revert them back in the same session.
73+
74+
## Visual Studio Code
75+
6076
In the context of Visual Studio Code, configuration settings can be set in the
6177
User, Remote or Workspace `settings.json` file or the [multi-root workspace
6278
file](https://code.visualstudio.com/docs/editor/multi-root-workspaces) by
@@ -73,6 +89,8 @@ prefixing each setting name with `ada.`, e.g.
7389
}
7490
```
7591

92+
These settings are sent to the ALS in the LSP `initialize` request, and then in `workspace/didChangeConfiguration` notifications if they get updated.
93+
7694
## Settings
7795

7896
Settings taken into account only from the Ada & SPARK VS Code extension:
@@ -325,9 +343,33 @@ This option controls if the `textDocument/onTypeFormatting` request only indents
325343
it additionally tries to format the previous node. By default, this option is enabled, that is,
326344
`textDocument/onTypeFormatting` only indents new lines.
327345

346+
In ALS config files, this setting must be specified in a nested form:
347+
348+
```json
349+
{
350+
"onTypeFormatting": {
351+
"indentOnly": true
352+
}
353+
}
354+
```
355+
356+
Conversely, in VS Code this settings can be set without nesting:
357+
358+
```json
359+
{
360+
"ada.onTypeFormatting.indentOnly": true,
361+
}
362+
```
363+
328364
### useGnatformat
329365

330366
This option controls the formatting provider for the `textDocument/formatting`,
331367
`textDocument/rangeFormatting` and `textDocument/onTypeFormatting` request. By default, this option
332368
is enabled and ALS uses GNATformat as its formatting provider. If disabled, GNATpp is used instead.
333369

370+
### logThreshold
371+
372+
Controls the maximum number of trace files preserved in the ALS log directory (which defaults to `~/.als`).
373+
When this threshold is reached, old trace files get deleted automatically.
374+
The default number of preserved trace files is `10`.
375+
See the documentation on [ALS Traces](doc/traces.md) for more information.

integration/vscode/ada/.vscode-test.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if (process.env['MOCHA_GREP']) {
3535
baseMochaOptions.grep = process.env['MOCHA_GREP'];
3636
}
3737

38-
const testsuites = ['general', 'gnattest', 'workspace_missing_dirs'];
38+
const testsuites = ['general', 'workspace_missing_dirs', 'dot-als-json'];
3939

4040
export default defineConfig(
4141
testsuites.map((suiteName) => {
@@ -65,8 +65,8 @@ export default defineConfig(
6565

6666
return {
6767
label: `Ada extension testsuite: ${suiteName}`,
68-
files: `out/test/suite/${suiteName}/**/*.test.js`,
69-
workspaceFolder: `./test/workspaces/${suiteName}`,
68+
files: `out/test/${suiteName}/**/*.test.js`,
69+
workspaceFolder: `./test/${suiteName}/ws`,
7070
mocha: mochaOptions,
7171
env: {
7272
// When working remotely on Linux, it is necessary to have "Xvfb
@@ -87,5 +87,5 @@ export default defineConfig(
8787
// Use external installation if provided in the VSCODE env variable
8888
useInstallation: process.env.VSCODE ? { fromPath: process.env.VSCODE } : undefined,
8989
};
90-
})
90+
}),
9191
);

integration/vscode/ada/package.json

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,14 @@
281281
"ada.projectFile": {
282282
"scope": "window",
283283
"type": "string",
284-
"default": "",
284+
"default": null,
285285
"description": "GPR project file (*.gpr) for this workspace.\n\nIt is recommended to set this to a relative path starting at the root of the workspace.",
286286
"order": 0
287287
},
288288
"ada.scenarioVariables": {
289289
"scope": "window",
290290
"type": "object",
291-
"default": {},
291+
"default": null,
292292
"description": "Scenario variables to apply to the GPR project file.\n\nThis value should be provided as an object where the property names are GPR scenario variables and the values are strings.",
293293
"patternProperties": {
294294
".*": {
@@ -300,26 +300,26 @@
300300
"ada.projectDiagnostics": {
301301
"scope": "window",
302302
"type": "boolean",
303-
"default": true,
303+
"default": null,
304304
"description": "Controls whether or not the Ada Language Server should emit project diagnostics into the VS Code Problems view.\n\nNote: this setting is ignored if `ada.enableDiagnostics` is disabled and a workspace reload is necessary to refresh the diagnostics after modifying this setting."
305305
},
306306
"ada.defaultCharset": {
307307
"scope": "window",
308308
"type": "string",
309-
"default": "iso-8859-1",
309+
"default": null,
310310
"description": "The character set that the Ada Language Server should use when reading files from disk."
311311
},
312312
"ada.relocateBuildTree": {
313313
"scope": "window",
314314
"type": "string",
315-
"default": "",
315+
"default": null,
316316
"description": "The folder for out-of-tree build.",
317317
"markdownDescription": "The path to a directory used for out-of-tree builds. This feature is related to the [--relocate-build-tree GPRbuild command line switch](https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/building_with_gprbuild.html#switches)."
318318
},
319319
"ada.rootDir": {
320320
"scope": "window",
321321
"type": "string",
322-
"default": "",
322+
"default": null,
323323
"markdownDescription": "This setting must be used in conjunction with the `relocateBuildTree` setting.\n\nIt specifies the root directory for artifact relocation. It corresponds to the [--root-dir GPRbuild command line switch](https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/building_with_gprbuild.html#switches)."
324324
}
325325
}
@@ -332,13 +332,13 @@
332332
"ada.useGnatformat": {
333333
"scope": "window",
334334
"type": "boolean",
335-
"default": true,
335+
"default": null,
336336
"markdownDescription": "Enable GNATformat as the formatting provider for Ada source files."
337337
},
338338
"ada.onTypeFormatting.indentOnly": {
339339
"scope": "window",
340340
"type": "boolean",
341-
"default": true,
341+
"default": null,
342342
"markdownDescription": "If the VS Code `editor.formatOnType` setting is enabled, the Ada Language Server will format Ada code while it is being typed in the editor, in particular when a new line is typed.\n\nThis setting controls whether formatting should only perform the indentation of the new line (true) or also format the previous line (false)."
343343
}
344344
}
@@ -364,7 +364,7 @@
364364
"Default style, based on GNAT coding standard with some enhancements.",
365365
"Documentation for the entities extracted from the comments before the entity declaration."
366366
],
367-
"default": "gnat",
367+
"default": null,
368368
"description": "Controls the primary documentation style of entities."
369369
},
370370
"ada.displayMethodAncestryOnNavigation": {
@@ -382,43 +382,43 @@
382382
"List overriding and/or overridden subprograms on declarations only.",
383383
"Always list overriding and/or overridden subprograms when possible."
384384
],
385-
"default": "usage_and_abstract_only",
385+
"default": null,
386386
"description": "Controls the policy for displaying overriding and overridden subprograms on navigation requests such as 'Go To Definition' or 'Go To Implementations'."
387387
},
388388
"ada.enableDiagnostics": {
389389
"scope": "window",
390390
"type": "boolean",
391-
"default": true,
391+
"default": null,
392392
"description": "Controls whether or not the Ada Language Server should emit diagnostics into the VS Code Problems view."
393393
},
394394
"ada.foldComments": {
395395
"scope": "window",
396396
"type": "boolean",
397-
"default": true,
397+
"default": null,
398398
"description": "Controls whether comments should be folded like code blocks."
399399
},
400400
"ada.namedNotationThreshold": {
401401
"scope": "window",
402402
"type": "integer",
403-
"default": 3,
403+
"default": null,
404404
"description": "Defines the number of parameters/components beyond which named notation is used for completion snippets."
405405
},
406406
"ada.useCompletionSnippets": {
407407
"scope": "window",
408408
"type": "boolean",
409-
"default": false,
409+
"default": null,
410410
"description": "Enable snippets in completion results (e.g. subprogram calls)."
411411
},
412412
"ada.insertWithClauses": {
413413
"scope": "window",
414414
"type": "boolean",
415-
"default": false,
415+
"default": null,
416416
"description": "Enable insertion of missing with-clauses when accepting completion for invisible symbols."
417417
},
418418
"ada.renameInComments": {
419419
"scope": "window",
420420
"type": "boolean",
421-
"default": false,
421+
"default": null,
422422
"description": "Enable editing Ada comments to update references to an entity when it is being renamed."
423423
}
424424
}
@@ -430,13 +430,13 @@
430430
"ada.enableIndexing": {
431431
"scope": "window",
432432
"type": "boolean",
433-
"default": true,
433+
"default": null,
434434
"description": "Controls whether the Ada Language Server should index the source files immediately after loading a project.\n\nIf set to false, indexing will be deferred to the time when an action requiring the index is first performed, e.g. hovering over a referenced entity to get its documentation."
435435
},
436436
"ada.followSymlinks": {
437437
"scope": "window",
438438
"type": "boolean",
439-
"default": true,
439+
"default": null,
440440
"description": "Controls the Ada Language Server normalizes the file paths received from the client."
441441
},
442442
"ada.trace.server": {
@@ -470,10 +470,22 @@
470470
],
471471
"default": "off",
472472
"description": "Traces the communication between VS Code and the GPR language server in the 'GPR Language Server' Output view."
473+
},
474+
"ada.logThreshold": {
475+
"scope": "window",
476+
"type": "integer",
477+
"default": null,
478+
"description": "Controls the maximum number of trace files preserved in the ALS log directory (which defaults to `~/.als`). When this threshold is reached, old trace files get deleted automatically. The default number of preserved trace files is `10`."
473479
}
474480
}
475481
}
476482
],
483+
"jsonValidation": [
484+
{
485+
"fileMatch": ".als.json",
486+
"url": "./schemas/als-settings-schema.json"
487+
}
488+
],
477489
"problemMatchers": [
478490
{
479491
"name": "ada",

0 commit comments

Comments
 (0)