From 96a9b5f93bcfdc553695d9177ead97366423c3cc Mon Sep 17 00:00:00 2001 From: Arne Brasseur Date: Fri, 22 Jan 2021 08:30:05 +0100 Subject: [PATCH] Add a configuration option to disable diagnostics Closes #980 --- CHANGELOG.md | 2 ++ package.json | 5 +++++ src/lsp.ts | 3 +++ src/state.ts | 3 ++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee30cad39..6c31c0cf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Changes to Calva. ## [Unreleased] +- [Add a configuration option to disable diagnostics](https://github.com/BetterThanTomorrow/calva/pull/981) + ## [2.0.171] - 2021-02-10 - Update clojure-lsp to version 2021.02.09-18.28.06 (Fix: [Auto completion does not work in clojure-lsp only mode (no repl connection)](https://github.com/BetterThanTomorrow/calva/issues/996#issuecomment-776148282)) - Update clojure-lsp to version 2021.02.10-03.01.19 (Fix: [Project clj-kondo config file not being considered](https://github.com/BetterThanTomorrow/calva/issues/1026)) diff --git a/package.json b/package.json index d6141fccd..cf3366628 100644 --- a/package.json +++ b/package.json @@ -509,6 +509,11 @@ "type": "boolean", "markdownDescription": "Don't surface REPL UI elements when avoidable. (For when using another REPL extension together with Calva's static features.)", "default": false + }, + "calva.displayDiagnostics": { + "type": "boolean", + "markdownDescription": "Show linter warnings and other diagnostics", + "default": true } } }, diff --git a/src/lsp.ts b/src/lsp.ts index 847ae5917..ecb0fa3b1 100644 --- a/src/lsp.ts +++ b/src/lsp.ts @@ -29,6 +29,9 @@ function createClient(jarPath: string): LanguageClient { }, middleware: { handleDiagnostics(uri, diagnostics, next) { + if (!state.config().displayDiagnostics) { + return; + } if (uri.path.endsWith(config.REPL_FILE_EXT)) { return; } diff --git a/src/state.ts b/src/state.ts index a49f55e1b..ec00949de 100644 --- a/src/state.ts +++ b/src/state.ts @@ -122,6 +122,7 @@ function config() { autoOpenJackInTerminal: configOptions.get("autoOpenJackInTerminal") as boolean, referencesCodeLensEnabled: configOptions.get('referencesCodeLens.enabled') as boolean, hideReplUi: configOptions.get('hideReplUi') as boolean, + displayDiagnostics: configOptions.get('displayDiagnostics') as boolean, }; } @@ -243,7 +244,7 @@ async function findProjectRootUri(projectFileNames, doc, workspaceFolder): Promi catch { } } } - catch (e) { + catch (e) { console.error(`Problems in search for project root directory: ${e}`); } prev = searchUri;