Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a configuration option to disable diagnostics #981

Merged
merged 1 commit into from
Feb 17, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
bpringe marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions src/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ function createClient(jarPath: string): LanguageClient {
},
middleware: {
handleDiagnostics(uri, diagnostics, next) {
if (!state.config().displayDiagnostics) {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this, I noticed when the setting is unchecked, whatever linter warnings existed before are not cleared, even when the user types in the relevant files. If we return next(uri, []) then the lint warnings will be cleared when the file is changed (and maybe other events like reopening it).

I'll make this change if you don't have time, just didn't want to modify your PR without checking with you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to run with it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And thanks a lot!

}
if (uri.path.endsWith(config.REPL_FILE_EXT)) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down Expand Up @@ -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;
Expand Down