Skip to content

Commit 17dfefa

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 707598e + 7e32ee8 commit 17dfefa

File tree

4 files changed

+55
-46
lines changed

4 files changed

+55
-46
lines changed

README.md

+41-42
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,33 @@ Here are some links that will help you get familiar with the VS Code extension f
137137

138138
### Configuration
139139

140-
You can configure the extension via the `.vscode/settings.json` workspace settings file or the [multi-root workspace file](https://code.visualstudio.com/docs/editor/multi-root-workspaces).
141-
More information about settings and the different ways that can be used to specify them can be found [here](doc/settings.md).
140+
[ALS settings](doc/settings.md) can be specified in various ways. For example:
141+
142+
- A `.als.json` file at the root of the workspace.
143+
- A global user configuration file `$HOME/.config/als/config.json`
144+
- The `.vscode/settings.json` VS Code workspace settings file.
145+
- A [multi-root VS Code workspace file](https://code.visualstudio.com/docs/editor/multi-root-workspaces)
146+
- The User or Remote or other VS Code [scopes of of settings](https://code.visualstudio.com/docs/configure/settings#_settings-precedence)
147+
148+
The `.als.json` file is the preferred method of defining workspace-specific settings because it applies in any IDE or editor that uses ALS. More information about configuration files can be found [here](doc/settings.md).
142149

143150
Here is an example config file that sets the project file to use and the scenario variables, as well as other useful settings (charset, whether we should show file diagnostics etc.):
144151

152+
```json
153+
{
154+
"projectFile": "gnatcov.gpr",
155+
"scenarioVariables": {
156+
"BINUTILS_BUILD_DIR": "/null",
157+
"BINUTILS_SRC_DIR": "/null"
158+
},
159+
"defaultCharset": "utf-8",
160+
"adaFileDiagnostics": false,
161+
"renameInComments": false
162+
}
163+
```
164+
165+
Alternatively, the ALS can be configured in the VS Code settings UI or in the JSON settings files. For example:
166+
145167
```json
146168
{
147169
"ada.projectFile": "gnatcov.gpr",
@@ -333,8 +355,8 @@ program using GNATemulator.
333355
<img src="doc/media/gnatemu-debug-codelens.gif" width="800" alt="Debug with GNATemulator CodeLens" />
334356

335357
The port used by the debugger launched by VS Code to connect to the running GNATemulator instance
336-
is the one specified via the `Emulator'Debug_Port` project attribute, so make sure it is set before
337-
running the dedicated GNATemulator command/CodeLens.
358+
is the one specified via the `Emulator'Debug_Port` project attribute: when not set, the extension
359+
will fallback on `localhost:1234` (GNATemulator's default debug port).
338360

339361
Note that GNATemulator is not available for all GNAT embedded toolchains. For more information about GNATemulator itself and its availabilty please refer to the [GNATemulator User's Guide](https://docs.adacore.com/gnatemulator-docs/gnatemulator.html).
340362

@@ -450,6 +472,8 @@ configure the Ada Language Server with `:CocConfig`:
450472
}
451473
```
452474

475+
Alternatively to the above settings section, workspace-specific [ALS Settings](doc/settings.md) such as the `projectFile` can be provided in a `.als.json` file at the root of the workspace.
476+
453477
### Integration with vim-lsp
454478

455479
If you want to integrate the Ada Language Server into vim, you can use the
@@ -464,13 +488,12 @@ if executable('ada_language_server')
464488
\ 'name': 'ada_language_server',
465489
\ 'cmd': ['ada_language_server'],
466490
\ 'allowlist': ['ada'],
467-
\ 'workspace_config': {'ada': {
468-
\ 'projectFile': "project.gpr",
469-
\ 'scenarioVariables': {"ARCH": "x86_64-pc-linux-gnu"}}},
470491
\ })
471492
endif
472493
```
473494

495+
Workspace-specific [ALS Settings](doc/settings.md) such as the `projectFile` can be provided in a `.als.json` file at the root of the workspace.
496+
474497
### Integration with LanguageClient-Neovim
475498

476499
If you want to integrate the Ada Language Server into Neovim, you can use the
@@ -487,33 +510,7 @@ let g:LanguageClient_serverCommands = {
487510
" if you already have LanguageClient_serverCommands, just add a line for ada.
488511
```
489512

490-
To configure the Ada Language Server for a specific workspace/project, you can
491-
use the `.vim/settings.json` file. It is mandatory as soon as you want to use a
492-
specific `.gpr` project file.
493-
494-
This is the way to specify a project file, eg. you cannot open a project file
495-
another way.
496-
See the setting list [here](doc/settings.md).
497-
498-
Here is an example of a settings file:
499-
500-
```json
501-
{
502-
"ada.projectFile": "project.gpr",
503-
"ada.scenarioVariables": {
504-
"GLFW_Version": "3",
505-
"GLFW_Lib": "-lglfw",
506-
"Windowing_System": "x11"
507-
}
508-
}
509-
```
510-
511-
The location where the `.vim` folder is located will determine the relative
512-
path of the project file (so no need to prefix with `..`). When vim is opened
513-
in the folder containing this `.vim` directory, it will use those settings for
514-
the language server *even for files which might have nothing to do with that
515-
specific project*, so this needs to be taken into account. Ultimately what this
516-
means is that the configuration is determined by where you open vim.
513+
Workspace-specific [ALS Settings](doc/settings.md) such as the `projectFile` can be provided in a `.als.json` file at the root of the workspace.
517514

518515
### Integration with Neovim's built-in LSP client
519516

@@ -533,7 +530,7 @@ the lsp client an absolute path to the ALS executable:
533530
require('lspconfig').ada_ls.setup{ cmd = "/path/to/als/executable" }
534531
```
535532

536-
Configuring the language server's settings can be achieved like this:
533+
Configuring the language server's settings globally can be achieved like this:
537534

538535
```lua
539536
require('lspconfig').ada_ls.setup{
@@ -546,13 +543,16 @@ require('lspconfig').ada_ls.setup{
546543
}
547544
```
548545

549-
The Ada Language Server's settings are described [here](doc/settings.md).
550-
Configuring neovim to use project-specific settings is described neovim's
546+
Workspace-specific [ALS Settings](doc/settings.md) such as the `projectFile` can be provided in a `.als.json` file at the root of the workspace.
547+
548+
Alternatively, workspace-specific settings can also be configured as per the
551549
[lspconfig wiki](https://github.com/neovim/nvim-lspconfig/wiki/Project-local-settings)
552550

553551
### Integration with emacs lsp-mode
554552

555-
The configuration for each project can be provided using a `.dir-locals.el`
553+
Workspace-specific [ALS Settings](doc/settings.md) such as the `projectFile` can be provided in a `.als.json` file at the root of the workspace.
554+
555+
Alternatively the configuration for each project can be provided using a `.dir-locals.el`
556556
file defined at the root of each project.
557557

558558
The scenario variables should be declared in your `.emacs` or any loaded
@@ -595,10 +595,9 @@ Starting with version `4.9`, QtCreator supports a LSP plugin. Follow
595595
[the official documentation](https://doc.qt.io/qtcreator/creator-language-servers.html)
596596
to configure the Ada Language Server in this plugin. Make sure to set `Startup behavior`
597597
to `Start Server per Project`, otherwise QtCreator won't provide the project root to
598-
the Ada Language Server. QtCreator doesn't send any configuration request to the language server, so the only
599-
option to enable project support is to have a single `.gpr` file in the QtCreator
600-
project folder. For a projectless configuration, you could also place all Ada sources in
601-
the project root folder, this should work as well.
598+
the Ada Language Server.
599+
600+
Workspace-specific [ALS Settings](doc/settings.md) such as the `projectFile` can be provided in a `.als.json` file at the root of the workspace.
602601

603602
## Refactoring Tools
604603

doc/settings.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The ALS loads configuration settings from different sources. All configuration sources are loaded in the following order:
66

7-
1. A global user configuration file `$XDG_CONFIG_HOME/als/config.json`, if it exists.
7+
1. A global user configuration file `$XDG_CONFIG_HOME/als/config.json`, if it exists. The path [defaults](https://specifications.freedesktop.org/basedir-spec/0.8/#variables) to `$HOME/.config/als/config.json` if `XDG_CONFIG_HOME` is not set.
88

99
1. A workspace-specific `.als.json` file in the directory where ALS is spawned, if it exists.
1010

integration/vscode/ada/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ This extension **does not include a compiler nor additional tools**. Nonetheless
3333
| | Debug ||
3434
| **GNAT DAS** | | |
3535
| | Test ||
36-
| | Code Coverage | 🚧 |
36+
| | Code Coverage | |
3737
| **GNAT SAS** | | |
3838
| | Static Analysis ||
3939
| **SPARK** | | |
4040
| | Formal Proof ||
4141

42-
🚧 _= The integration of this tool feature in Visual Studio Code is in progress._
43-
4442
## Getting Additional Tools
4543

4644
For a fully operational development environment you can obtain a compiler and/or other tools from the following channels.

integration/vscode/ada/src/commands.ts

+12
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ async function buildAndDebugSpecifiedMain(
726726
const adaMain = await findAdaMain(main.fsPath);
727727
const target = await adaExtState.getTargetPrefix();
728728
const debugServerAddress = await adaExtState.getDebugServerAddress(useGNATemulator);
729+
729730
if (adaMain) {
730731
/**
731732
* The vscode API doesn't provide a way to list both automatically
@@ -762,6 +763,17 @@ async function buildAndDebugSpecifiedMain(
762763
if (matchingConfig) {
763764
logger.debug('Found matching config: ' + JSON.stringify(matchingConfig, null, 2));
764765

766+
// No debug server address specified in matching debug configuration: fallback
767+
// to 'localhost:1234' to match GNATemulator's default debug port.
768+
if (!matchingConfig.miDebuggerServerAddress && useGNATemulator) {
769+
const fallbackDebugServerAddress = 'localhost:1234';
770+
logger.debug(
771+
`No debug server address specified in debug configuration for GNATemulator:
772+
use '${fallbackDebugServerAddress}' as a fallback`,
773+
);
774+
matchingConfig.miDebuggerServerAddress = 'localhost:1234';
775+
}
776+
765777
// Trying to debug via GNATemulator: run the main via GNATemulator in debug mode
766778
// before starting the debug session
767779
if (useGNATemulator) {

0 commit comments

Comments
 (0)