From 26db0cc2447b0288f5ecc6edea5d20772e4c1f29 Mon Sep 17 00:00:00 2001 From: Remi Thebault Date: Mon, 5 Jun 2023 21:41:36 +0200 Subject: [PATCH] lint CCDB on file open --- source/served/extension.d | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/served/extension.d b/source/served/extension.d index 1fe7871..682ea94 100644 --- a/source/served/extension.d +++ b/source/served/extension.d @@ -948,7 +948,10 @@ void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) @protocolNotification("textDocument/didOpen") void onDidOpenDocument(DidOpenTextDocumentParams params) { - string lintSetting = config(params.textDocument.uri).d.lintOnFileOpen; + auto config = workspace(params.textDocument.uri).config; + auto document = documents[params.textDocument.uri]; + + string lintSetting = config.d.lintOnFileOpen; bool shouldLint; if (lintSetting == "always") shouldLint = true; @@ -956,9 +959,18 @@ void onDidOpenDocument(DidOpenTextDocumentParams params) shouldLint = workspaceIndex(params.textDocument.uri) != size_t.max; if (shouldLint) + { onDidChangeDocument(DidChangeTextDocumentParams( VersionedTextDocumentIdentifier( params.textDocument.uri, params.textDocument.version_))); + + if (config.d.enableCcdbLinting && document.languageId == "d") + { + import served.linters.ccdb; + + lint(document); + } + } } @protocolNotification("textDocument/didClose")