diff --git a/docs/readthedocs/source/customizing.md b/docs/readthedocs/source/customizing.md index 395d8c1bc..ff3a396fe 100644 --- a/docs/readthedocs/source/customizing.md +++ b/docs/readthedocs/source/customizing.md @@ -77,10 +77,3 @@ The change would look like this in your `keybindings.json`: "when": "editorHasSelection && editorTextFocus && !editorReadOnly && editorLangId =~ /clojure|scheme|lisp/ && paredit:keyMap =~ /original|strict/" } ``` - -## Autolinting - -The extension comes with autolinting disabled. This is because you will need to have [Joker](https://github.com/candid82/joker) installed in order for it to work. You will probably want to have Joker installed regardless so, just do it and then enable autolinting by setting: -```json -"calva.lintOnSave": true -``` \ No newline at end of file diff --git a/docs/readthedocs/source/index.rst b/docs/readthedocs/source/index.rst index 275c2938f..abb48c609 100644 --- a/docs/readthedocs/source/index.rst +++ b/docs/readthedocs/source/index.rst @@ -36,6 +36,7 @@ I'm glad you asked! Please see the `Calva Development Wiki { console.warn(`Namespace sync failed, becauase: ${reasons}`) }); + .catch(reasons => { console.warn(`Namespace sync failed, because: ${reasons}`) }); } } })); @@ -215,7 +203,7 @@ function activate(context: vscode.ExtensionContext) { vscode.commands.executeCommand('setContext', 'calva:activated', true); - greetings.activationGreetings(chan, lint); + greetings.activationGreetings(chan); if (vimExtension) { chan.appendLine(`VIM Extension detected. Please read: ${VIM_DOC_URL} now and then.\n`); diff --git a/src/greet.ts b/src/greet.ts index 61987ef7d..6d9c15084 100644 --- a/src/greet.ts +++ b/src/greet.ts @@ -1,11 +1,7 @@ -export function activationGreetings(chan, lintEnabled) { +export function activationGreetings(chan) { chan.appendLine("Happy Clojure(script) coding! ❤️"); + chan.appendLine("The Calva Team welcome you to the #calva-dev channel of the Clojurians Slack: https://clojurians.slack.com/messages/calva-dev/"); chan.appendLine("Please file any feature requests or bug reports here: https://github.com/BetterThanTomorrow/calva/issues"); - chan.appendLine("I will also respond to any @pez mentions in the #calva-dev channel of the Clojurians Slack: https://clojurians.slack.com/messages/calva-dev/"); - chan.appendLine(""); - if (!lintEnabled) { - chan.appendLine("") - chan.appendLine("NOTE: Autolinting is disabled. You need to enable \"calva.lintOnSave\" in your editor settings to use it. But first install Joker: https://github.com/candid82/joker"); - } + chan.appendLine("NOTE: Calva bundles the clj-kondo extension for your linting needs. Please see: https://calva.readthedocs.io/en/latest/linting.html"); chan.appendLine("--"); } \ No newline at end of file diff --git a/src/lint.ts b/src/lint.ts deleted file mode 100644 index c04f46d0b..000000000 --- a/src/lint.ts +++ /dev/null @@ -1,100 +0,0 @@ -import * as vscode from 'vscode'; -import { spawn } from 'child_process'; -import * as path from 'path'; -import * as state from './state'; -import * as util from './utilities'; -import { windowsToWslSync } from 'wsl-path'; - -function parseJokerLine(jokerOutput) { - const OUTPUT_REGEXP = /.+:([0-9]+)+:([0-9]+): (.+)/, - matches = OUTPUT_REGEXP.exec(jokerOutput); - - if (!matches) { - console.warn("joker: could not parse output:", jokerOutput) - return null; - } - - const message = { - line: parseInt(matches[1]), - reason: matches[3], - column: parseInt(matches[2]) - 1, - type: matches[3].includes("warning") ? util.ERROR_TYPE.WARNING : util.ERROR_TYPE.ERROR - } - - if (!message.line) { - console.warn("joker: could not find line number:", jokerOutput) - return null; - } - - return message -} - -function markMessage(msg) { - if (msg.type == util.ERROR_TYPE.ERROR) { - util.markError(msg); - } - else if (msg.type == util.ERROR_TYPE.WARNING) { - util.markWarning(msg); - } -} - -function buildJokerPath(jokerPath, join) { - return jokerPath === "joker" ? "joker" : join(jokerPath, "joker"); -} - -function jokerChildProcess(fileName) { - let { jokerPath, useWSL } = state.config(); - if (useWSL) { - const wslFilePath = windowsToWslSync(fileName); - return spawn("wsl", [buildJokerPath(jokerPath, path.posix.join), "--lint", wslFilePath]); - } - return spawn(buildJokerPath(jokerPath, path.join), ["--lint", fileName]); -} - -function lintDocument(document = {}) { - let doc = util.getDocument(document); - - if (doc && doc.languageId !== 'clojure') { - return; - } - //Reset errors - state.deref().get("diagnosticCollection").delete(doc.uri); - - let joker = jokerChildProcess(doc.fileName); - joker.stdout.setEncoding("utf8"); - - joker.stderr.on("data", (data) => { - if (data.length != 0) { - for (let jokerLine of data.toString().split(/\r?\n/)) { - if (jokerLine.length != 0) { - let msg = parseJokerLine(jokerLine) - if (msg != null) { - markMessage(msg); - } - } - } - } - }); - - joker.on("error", (error: { message, code }) => { - let { - lint, - jokerPath - } = state.config() - let nojoker = error.code == "ENOENT"; - if (nojoker) { - const errmsg = `linting error: unable to locate '${jokerPath}'`, - autolintmsg = "You have autolinting enabled. If you want to disable auto-linting set calva.lintOnSave to false in settings"; - vscode.window.showErrorMessage("calva " + errmsg); - if (lint) { - vscode.window.showWarningMessage("calva " + autolintmsg); - } - } else { - vscode.window.showErrorMessage("calva " + "linting error: " + error.message); - } - }); -} - -export default { - lintDocument -}; diff --git a/src/state.ts b/src/state.ts index bd8653ea2..7de8f875b 100644 --- a/src/state.ts +++ b/src/state.ts @@ -99,9 +99,7 @@ function config() { return { format: configOptions.get("formatOnSave"), evaluate: configOptions.get("evalOnSave"), - lint: configOptions.get("lintOnSave"), test: configOptions.get("testOnSave"), - jokerPath: configOptions.get("jokerPath"), useWSL: configOptions.get("useWSL"), syncReplNamespaceToCurrentFile: configOptions.get("syncReplNamespaceToCurrentFile"), jackInEnv: configOptions.get("jackInEnv"),