Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
branches:
- main
pull_request:
schedule:
# Every week, to notice when the web services that the tests use change.
- cron: "23 5 * * 1"

jobs:
server:
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ authors and references it defines.
(<kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> on macOS) and run
**ESMValTool: Restart Language Server**; in Emacs, run
`M-x eglot-reconnect`.
- Errata of the datasets in a recipe, from the
[ESGF errata service](https://errata.esgf.io), shown on the line of the
dataset with their status and a link to the description.
They are shown as information, to distinguish them from errors and warnings
about the recipe itself.
Resolved errata are only shown for a dataset with an affected `version`.
To find them, the project, name, and experiment of each dataset are sent to
the service, which can take up to a minute for a recipe with many models.
The answers are kept for a day.
Turn this off with the setting `esmvaltool.languageServer.errata` in Visual
Studio Code, or with the initialization option `errata` in other editors.
- Go to the definition of a preprocessor, of a task listed in `ancestors`,
of the dataset in `reference_dataset` or `alternative_dataset`, or of a
diagnostic script.
Expand Down Expand Up @@ -168,6 +179,8 @@ command, for example `"/path/to/env/bin/esmvaltool-language-server"`.
Problems are shown with Flymake, completion works with
`completion-at-point` (`C-M-i`), documentation is shown by ElDoc, and `M-.`
goes to a definition.
To turn off the errata of datasets, add `:initializationOptions (:errata
:json-false)` after `"--stdio"` in the command above.

## Development

Expand Down Expand Up @@ -198,9 +211,9 @@ npm run package # build a package that can be installed
```

The tests marked `network` need internet access.
They check the Essential Model Documentation of CMIP7 models and the links in
the recipe schema and in the documentation shown when hovering over tags,
references, and facets.
They check the Essential Model Documentation of CMIP7 models, the API of the
ESGF errata service, and the links in the recipe schema and in the documentation
shown when hovering over tags, references, and facets.
Links to the latest documentation of ESMValCore and ESMValTool are checked
against the documentation of the development versions that the server is
developed with; to use other documentation, set `ESMVALCORE_DOCS` or
Expand Down
5 changes: 5 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
"type": "string",
"default": "",
"markdownDescription": "Python interpreter of the environment where ESMValTool and the language server are installed. If empty, the interpreter selected in the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) is used."
},
"esmvaltool.languageServer.errata": {
"type": "boolean",
"default": true,
"markdownDescription": "Show [errata](https://errata.esgf.io) of the datasets in a recipe. To find them, the project, name, and experiment of the datasets are sent to the ESGF errata service."
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function enqueue(operation: () => Promise<void>): Promise<void> {
/** The API of this extension, used by its tests. */
export interface Api {
readonly mode: Mode;
/** The errata option that was sent to the running language server. */
readonly errataOption: boolean | undefined;
/** Check if a file is a recipe, for the schema. */
isRecipe(resource: string): boolean;
}
Expand Down Expand Up @@ -56,6 +58,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<Api> {
}
await enqueue(start);
return {
get errataOption() {
const options = client?.clientOptions.initializationOptions as
{ errata?: boolean } | undefined;
return options?.errata;
},
get mode() {
return schemaFallback.mode;
},
Expand Down Expand Up @@ -97,6 +104,11 @@ async function start(): Promise<void> {
};
const clientOptions: LanguageClientOptions = {
documentSelector: [RECIPE_SELECTOR],
initializationOptions: {
errata: vscode.workspace
.getConfiguration("esmvaltool.languageServer")
.get<boolean>("errata", true),
},
};
const starting = new LanguageClient(
"esmvaltool",
Expand Down
30 changes: 30 additions & 0 deletions client/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,36 @@ describe("ESMValTool extension", () => {
assert.equal(extension.exports.isRecipe(document.uri.toString()), true);
});

it("sends the errata setting to the language server", async () => {
const extension = vscode.extensions.getExtension<{
errataOption: boolean | undefined;
mode: string;
}>("ESMValGroup.esmvaltool");
assert.ok(extension);
const api = extension.exports;
assert.equal(api.errataOption, true);
const settings = vscode.workspace.getConfiguration(
"esmvaltool.languageServer",
);
await settings.update("errata", false, vscode.ConfigurationTarget.Global);
try {
await waitFor(
() => (api.errataOption === false ? true : undefined),
"the errata setting",
);
} finally {
await settings.update(
"errata",
undefined,
vscode.ConfigurationTarget.Global,
);
}
await waitFor(
() => (api.errataOption === true ? true : undefined),
"the default errata setting",
);
});

it("falls back to the schema without the language server", async () => {
const extension = vscode.extensions.getExtension<{ mode: string }>(
"ESMValGroup.esmvaltool",
Expand Down
1 change: 1 addition & 0 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies = [
"pygls>=2.0",
"pyyaml",
"requests",
"requests-cache",
]
description = "Language server for ESMValTool recipes"
license = "Apache-2.0"
Expand Down Expand Up @@ -155,6 +156,7 @@ xarray = "*"
zarr = ">3"
globus-sdk = "*"
pygls = ">=2.0"
requests-cache = "*"

[tool.pixi.pypi-dependencies]
esmvaltool-language-server = { path = ".", editable = true }
Expand Down
Loading
Loading