Skip to content

Commit

Permalink
Add command evaluating top level to comment
Browse files Browse the repository at this point in the history
resolves #349
  • Loading branch information
PEZ committed Sep 26, 2019
1 parent 46208ce commit 048d009
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changes to Calva.

## [Unreleased]
- [Stop writing results from **Evaluate to Comment** to output pane](https://github.com/BetterThanTomorrow/calva/issues/347)
- [Add command for evaluating top level form as comment](https://github.com/BetterThanTomorrow/calva/issues/349)

## [2.0.40] - 25.09.2019
- [Add command for connecting to a non-project REPL](https://github.com/BetterThanTomorrow/calva/issues/328)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ Demo: switch between `clj` and `cljs` repl sessions for `cljc` files:
- Evaluate code at cursor and show the results as annotation in the editor: `ctrl+alt+c e` (`ctrl+alt+c v` on Windows)
- Dismiss the display of results by pressing `escape` (there is info on the wiki for **vim** extension users).
- Evaluate code and replace it in the editor, inline: `ctrl+alt+c r`
- Pretty printing evaluation results: `ctrl+alt+c p` (Currently broken, see issues on Github).
- Evaluate code and add as comment: `ctrl+alt+c c` (current form), `ctrl+alt+c ctrl space` (current _top level_ form)
- Pretty printing evaluation results: `ctrl+alt+c p`
- Evaluate current top level form (based on where the cursor is) and show results inline: `ctrl+alt+c space`
- Send the current top level form to the REPL terminal: `ctrl+alt+c ctrl+alt+space`
- Send the current top level form to the REPL window: `ctrl+alt+c ctrl+alt+space`
- Error information when evaluation fails (at least a hint)
- Support for `cljc` files and you can choose if they should be evaluated by the `clj` or the `cljc` repl session.
- Enables `clj` REPL for all files/editors. You now can evaluate those Clojure code snippets in Markdown files.
Expand Down
5 changes: 5 additions & 0 deletions calva/evaluate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ function evaluateSelectionAsComment(document = {}, options = {}) {
evaluateSelection(document, Object.assign({}, options, { comment: true, pprint: true }));
}

function evaluateTopLevelFormAsComment(document = {}, options = {}) {
evaluateSelection(document, Object.assign({}, options, { comment: true, topLevel: true, pprint: true }));
}

function evaluateSelectionPrettyPrint(document = {}, options = {}) {
evaluateSelection(document, Object.assign({}, options, { pprint: true }));
}
Expand Down Expand Up @@ -193,6 +197,7 @@ export default {
evaluateCurrentTopLevelFormPrettyPrint,
evaluateSelectionReplace,
evaluateSelectionAsComment,
evaluateTopLevelFormAsComment,
copyLastResultCommand,
requireREPLUtilitiesCommand
};
1 change: 1 addition & 0 deletions calva/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands.registerCommand('calva.evaluateCurrentTopLevelFormPrettyPrint', EvaluateMiddleWare.evaluateCurrentTopLevelFormPrettyPrint));
context.subscriptions.push(vscode.commands.registerCommand('calva.evaluateSelectionReplace', EvaluateMiddleWare.evaluateSelectionReplace));
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.lintFile', LintMiddleWare.lintDocument));
context.subscriptions.push(vscode.commands.registerCommand('calva.runTestUnderCursor', TestRunnerMiddleWare.runTestUnderCursorCommand));
context.subscriptions.push(vscode.commands.registerCommand('calva.runNamespaceTests', TestRunnerMiddleWare.runNamespaceTestsCommand));
Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,12 @@
},
{
"command": "calva.evaluateSelectionAsComment",
"title": "Evaluate current form, and append a comment with the result",
"title": "Evaluate current form, append a comment with the result",
"category": "Calva"
},
{
"command": "calva.evaluateTopLevelFormAsComment",
"title": "Evaluate current top level form, append a comment with the result",
"category": "Calva"
},
{
Expand Down Expand Up @@ -895,6 +900,10 @@
"command": "calva.evaluateSelectionAsComment",
"key": "ctrl+alt+c c"
},
{
"command": "calva.evaluateTopLevelFormAsComment",
"key": "ctrl+alt+c ctrl+space"
},
{
"command": "calva.copyLastResults",
"key": "ctrl+alt+c ctrl+c"
Expand Down

0 comments on commit 048d009

Please sign in to comment.