Skip to content

Commit

Permalink
Throwing out all linting code, bundling
Browse files Browse the repository at this point in the history
Closes #423
  • Loading branch information
PEZ committed Oct 24, 2019
1 parent 8b3a8db commit 448c6a7
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 166 deletions.
7 changes: 0 additions & 7 deletions docs/readthedocs/source/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
1 change: 1 addition & 0 deletions docs/readthedocs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ I'm glad you asked! Please see the `Calva Development Wiki <https://github.com/B
connect-sequences
custom-commands
workspace-layouts
linting
rebl
vim
wsl
Expand Down
9 changes: 9 additions & 0 deletions docs/readthedocs/source/linting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Linting

Calva does not linting at all. However, it bundles the [clj-kondo](https://marketplace.visualstudio.com/items?itemName=borkdude.clj-kondo) extension, which is powered by the [linter with the same name](https://github.com/borkdude/clj-kondo).

You might want to read about [how to configure clj-kondo](https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#configuration). These two sections might be of extra interest:
* [Exclude unresolved symbols from being reported](https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#exclude-unresolved-symbols-from-being-reported)
* [Lint a custom macro like a built-in macro](https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#lint-a-custom-macro-like-a-built-in-macro)

If you see clj-kondo squiggle the first character of the file with an error you don't quite understand, it is probably something wrong with your clj-kondo configuration. One such error could be from not knowing this: _Note that the symbols in the clj-kondo configuration need to be fully qualified, with namespaces._
19 changes: 5 additions & 14 deletions docs/readthedocs/source/quirks.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ Here's a shocker for ya': Calva isn't perfect. 😄

There are quirks and things that flat out do not work. We'll try to collect info about such things here, providing workarounds when available (or, rather, known to us).

## Strange linting errors?

The Joker way of linting is awesome, but has its limitations. If you think the linting reporting is off, it is probably something you should check with the [Joker project](https://github.com/candid82/joker).

That said, this one might be worth a mention here:

### Unrecognized macros
One thing to note with this linter is that it doesn't do a full scan of all files and does not recognize macros it doesn't know about. Leading to false complaints about `Unable to resolve symbol x`. You might now and then tell it about macros you use. Create a `.joker` file somewhere in the path from the root of your project to where you are using the macro (the project root might be the best choice), and add:
```clojure
{:known-macros [some-ns/some-macro some-other-ns/some-other-macro]}
```
Read more about Joker's linter mode here: https://github.com/candid82/joker#linter-mode

## Test features not available with ClojureScript

Currently [`cider-nrepl` does not provide its test functionality for ClojureScript](https://github.com/clojure-emacs/cider-nrepl/issues/555) code. Please consider contributing to fixing that.
Expand All @@ -36,4 +23,8 @@ To make slurping and barfing forward really easy to perform they are bound to `c

## Calva and the VIM Extension

See [Using Calva with the VIM Extension](vim.md)
See [Using Calva with the VIM Extension](vim.md).

## Strange linting errors?

See [linting](linting.md).
2 changes: 1 addition & 1 deletion docs/readthedocs/source/wsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

If you want to use this extension with WSL, there are a few things that need to be configured first.

1. The `useWSL` option must be set to `true` (And if you are using the linter, you must add a valid WSL path to the `jokerPath` option.)
1. The `useWSL` option must be set to `true`
2. After doing the previous step, you must restart Visual Studio Code.
3. Make sure that you have Windows 10 version 1803 since that's the version that includes the `wslpath` tool which is used to convert between WSL and Windows paths.
4. If you're using Leiningen and if you want to view definitions of source files (e.g. `println`, `defn`, `def`) you will need to change your .m2 directory to a location directly accessible by Windows. For example, you could edit your `~/.lein/profiles.clj` like so:
Expand Down
2 changes: 1 addition & 1 deletion docs/things-to-do.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The major themes are:

## The Right Features
* Support clj-fmt indent settings.
* Enable clj-kondo as default Calva linter ([clj-kondo](https://github.com/borkdude/clj-kondo/releases/tag/v2019.09.22-alpha) does support Windows but distributes no binary for Windows)
* [x] Enable clj-kondo as default Calva linter ([clj-kondo](https://github.com/borkdude/clj-kondo/releases/tag/v2019.09.22-alpha) does support Windows but distributes no binary for Windows)
* Enable using nrepl in streaming mode
* Use this for the test runner
* Add some basic refactorings support
Expand Down
24 changes: 4 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"workspaceContains:**/deps.edn"
],
"main": "./out/extension",
"extensionPack": [
"borkdude.clj-kondo"
],
"contributes": {
"languages": [
{
Expand Down Expand Up @@ -116,11 +119,6 @@
"default": false,
"description": "Run load-file when opening a new file and on file save"
},
"calva.lintOnSave": {
"type": "boolean",
"default": false,
"description": "Run joker-linting when opening a new file and on file save"
},
"calva.testOnSave": {
"type": "boolean",
"default": false,
Expand Down Expand Up @@ -198,15 +196,10 @@
"connectedRegExp"
]
},
"calva.jokerPath": {
"type": "string",
"default": "joker",
"description": "Sets the path in which the Joker executable can be found. If useWSL has been set to true, this should be a valid WSL path."
},
"calva.useWSL": {
"type": "boolean",
"default": false,
"description": "Specifies if the nREPL and Joker are running within WSL."
"description": "Specifies if the nREPL is running within WSL."
},
"calva.jackInEnv": {
"type": "object",
Expand Down Expand Up @@ -667,11 +660,6 @@
"enablement": "calva:connected",
"category": "Calva"
},
{
"command": "calva.lintFile",
"title": "Lint Current File",
"category": "Calva"
},
{
"command": "calva.runNamespaceTests",
"title": "Run Tests for Current Namespace",
Expand Down Expand Up @@ -1039,10 +1027,6 @@
"command": "calva.requireREPLUtilities",
"key": "ctrl+alt+c ctrl+u"
},
{
"command": "calva.lintFile",
"key": "ctrl+alt+c l"
},
{
"command": "calva.runNamespaceTests",
"key": "ctrl+alt+c t"
Expand Down
16 changes: 2 additions & 14 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import TextDocumentContentProvider from './providers/content';
import HoverProvider from './providers/hover';
import { DefinitionProvider } from './providers/definition';
import EvaluateMiddleWare from './evaluate';
import LintMiddleWare from './lint';
import TestRunnerMiddleWare from './testRunner';
import annotations from './providers/annotations';
import select from './select';
Expand All @@ -27,7 +26,6 @@ import statusbar from './statusbar';
function onDidSave(document) {
let {
evaluate,
lint,
test
} = state.config();

Expand All @@ -44,20 +42,12 @@ function onDidSave(document) {
EvaluateMiddleWare.loadFile(document);
state.analytics().logEvent("Calva", "OnSaveLoad").send();
}
if (lint) {
LintMiddleWare.lintDocument(document);
state.analytics().logEvent("Calva", "OnSaveLint").send();
}
}

function onDidOpen(document) {
if (document.languageId !== 'clojure') {
return;
}

if (state.config().lint) {
LintMiddleWare.lintDocument(document);
}
}


Expand Down Expand Up @@ -111,7 +101,6 @@ function activate(context: vscode.ExtensionContext) {
replWindow.activate(context);

chan.appendLine("Calva activated.");
let { lint } = state.config();

status.update();

Expand All @@ -137,7 +126,6 @@ function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands.registerCommand('calva.evaluateSelectionAsComment', EvaluateMiddleWare.evaluateSelectionAsComment));
context.subscriptions.push(vscode.commands.registerCommand('calva.evaluateTopLevelFormAsComment', EvaluateMiddleWare.evaluateTopLevelFormAsComment));
context.subscriptions.push(vscode.commands.registerCommand('calva.togglePrettyPrint', EvaluateMiddleWare.togglePrettyPrint));
context.subscriptions.push(vscode.commands.registerCommand('calva.lintFile', LintMiddleWare.lintDocument));
context.subscriptions.push(vscode.commands.registerCommand('calva.runTestUnderCursor', TestRunnerMiddleWare.runTestUnderCursorCommand));
context.subscriptions.push(vscode.commands.registerCommand('calva.runNamespaceTests', TestRunnerMiddleWare.runNamespaceTestsCommand));
context.subscriptions.push(vscode.commands.registerCommand('calva.runAllTests', TestRunnerMiddleWare.runAllTestsCommand));
Expand Down Expand Up @@ -199,7 +187,7 @@ function activate(context: vscode.ExtensionContext) {
const fileExtIfClj = editor.document.fileName.match(/\.clj[cs]?/);
if (fileExtIfClj && fileExtIfClj.length && state.config().syncReplNamespaceToCurrentFile) {
replWindow.setREPLNamespace(util.getDocumentNamespace(editor.document))
.catch(reasons => { console.warn(`Namespace sync failed, becauase: ${reasons}`) });
.catch(reasons => { console.warn(`Namespace sync failed, because: ${reasons}`) });
}
}
}));
Expand All @@ -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`);
Expand Down
10 changes: 3 additions & 7 deletions src/greet.ts
Original file line number Diff line number Diff line change
@@ -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("--");
}
100 changes: 0 additions & 100 deletions src/lint.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 448c6a7

Please sign in to comment.