From 24f83bd62448861155cc7254019a304903a4f27e Mon Sep 17 00:00:00 2001 From: Remy Willems Date: Thu, 9 May 2024 17:09:34 +0200 Subject: [PATCH] Dafny project file improvements (#475) ### Changes - No longer let the syntax definitions for .dfy files also be applied to dfyconfig.toml files - Activate extension when `.toml` file is opened, such as a `dfyconfig.toml` - Let the language client also operate on files ending in `dfyconfig.toml` ### Testing - Manually tested that only opening a `dfyconfig.toml` will already trigger the extension and provide diagnostics. - Manually tested that making changing in a `dfyconfig.toml` file causes diagnostics to be updated - Manually tested that syntax highlighting for `dfyconfig.toml` files works correctly. --- ...nfiguration.json => dafny-language-configuration.json | 0 package.json | 9 +++++---- src/language/dafnyLanguageClient.ts | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) rename language-configuration.json => dafny-language-configuration.json (100%) diff --git a/language-configuration.json b/dafny-language-configuration.json similarity index 100% rename from language-configuration.json rename to dafny-language-configuration.json diff --git a/package.json b/package.json index 72fd4fef..9acf9558 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,9 @@ "bugs": { "url": "https://github.com/dafny-lang/ide-vscode/issues" }, + "activationEvents": [ + "onLanguage:toml" + ], "qna": false, "license": "MIT", "galleryBanner": { @@ -123,10 +126,9 @@ ], "extensions": [ ".dfy", - ".dfyi", - "dfyconfig.toml" + ".dfyi" ], - "configuration": "./language-configuration.json" + "configuration": "./dafny-language-configuration.json" } ], "grammars": [ @@ -309,7 +311,6 @@ } ] }, - "activationEvents": [], "scripts": { "vscode:prepublish": "npm run package", "compile": "webpack", diff --git a/src/language/dafnyLanguageClient.ts b/src/language/dafnyLanguageClient.ts index dd08ec30..5a19fb03 100644 --- a/src/language/dafnyLanguageClient.ts +++ b/src/language/dafnyLanguageClient.ts @@ -152,7 +152,11 @@ export class DafnyLanguageClient extends LanguageClient { }; const diagnosticsListeners: ((uri: Uri, diagnostics: Diagnostic[]) => void)[] = []; const clientOptions: LanguageClientOptions = { - documentSelector: [ DafnyDocumentFilter ], + documentSelector: [ DafnyDocumentFilter, { + scheme: 'file', + pattern: '**/*dfyconfig.toml' + } + ], diagnosticCollectionName: LanguageServerId, middleware: { handleDiagnostics: (uri: Uri, diagnostics: Diagnostic[], next: HandleDiagnosticsSignature) => {