Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Sep 12, 2019
2 parents 0cc9001 + 2f69367 commit a433588
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 48 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ Changes to Calva. (We really will try to keep this updated now.)
## When time allows, this will be worked on
- [Support for custom project/workflow commands](https://github.com/BetterThanTomorrow/calva/issues/281)

## [Unreleased] -
## [Unreleased]
- Nothing to see here

## [2.0.36] - 12.09.2019
- Fix [REPL Window namespace being reset to user](https://github.com/BetterThanTomorrow/calva/issues/302)
- Update nrepl-version to 0.22.1

## [2.0.35] - 10.09.2019
- [Customizing the REPL connect sequence](https://github.com/BetterThanTomorrow/calva/issues/282)
Expand Down
3 changes: 2 additions & 1 deletion calva/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as projectTypes from './nrepl/project-types';

const { parseEdn } = require('../cljs-out/cljs-lib');
import { NReplClient, NReplSession } from "./nrepl";
import { reconnectReplWindow, openReplWindow, sendTextToREPLWindow } from './repl-window';
import { reconnectReplWindow, openReplWindow, sendTextToREPLWindow, createReplWindow } from './repl-window';
import { CljsTypeConfig, ReplConnectSequence, getDefaultCljsType, CljsTypes, askForConnectSequence } from './nrepl/connectSequence';

async function connectToHost(hostname, port, connectSequence: ReplConnectSequence) {
Expand Down Expand Up @@ -90,6 +90,7 @@ async function connectToHost(hostname, port, connectSequence: ReplConnectSequenc
async function setUpCljsRepl(cljsSession, chan, build) {
state.cursor.set("cljs", cljsSession);
chan.appendLine("Connected session: cljs" + (build ? ", repl: " + build : ""));
await createReplWindow(cljsSession, "cljs");
await openReplWindow("cljs", true);
await reconnectReplWindow("cljs");
status.update();
Expand Down
6 changes: 3 additions & 3 deletions calva/nrepl/project-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function shadowBuilds(): string[] {

const cliDependencies = {
"nrepl": "0.6.0",
"cider/cider-nrepl": "0.21.1",
"cider/cider-nrepl": "0.22.1",
}

const cljsCommonDependencies = {
Expand All @@ -56,7 +56,7 @@ const cljsDependencies: { [id: string]: Object } = {
"com.bhauman/figwheel-main": "0.2.3"
},
"shadow-cljs": {
"cider/cider-nrepl": "0.21.1",
"cider/cider-nrepl": "0.22.1",
},
"Nashorn": {
},
Expand All @@ -65,7 +65,7 @@ const cljsDependencies: { [id: string]: Object } = {
}

const leinPluginDependencies = {
"cider/cider-nrepl": "0.21.1"
"cider/cider-nrepl": "0.22.1"
}
const leinDependencies = {
"nrepl": "0.6.0",
Expand Down
63 changes: 35 additions & 28 deletions calva/repl-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ class REPLWindow {
let result = await this.session.info(msg.ns, msg.symbol);
this.postMessage({ type: "info", data: result });
}

if (msg.type == "focus") {
vscode.commands.executeCommand("setContext", "calva:replWindowActive", true);
vscode.commands.executeCommand("setContext", "calva:pareditValid", true);
}

if (msg.type == "blur") {
vscode.commands.executeCommand("setContext", "calva:replWindowActive", false);
}
Expand Down Expand Up @@ -203,52 +203,59 @@ export async function reconnectReplWindow(mode: "clj" | "cljs") {
}
}

export async function openReplWindow(mode: "clj" | "cljs" = "clj", preserveFocus: boolean = false) {
export async function openReplWindow(mode: "clj" | "cljs" = "clj", preserveFocus: boolean = true) {
let session = mode == "clj" ? cljSession : cljsSession,
nreplClient = session.client;

if (!replWindows[mode]) {
await createReplWindow(session, mode);
} else if (!nreplClient.sessions[replWindows[mode].session.sessionId]) {
replWindows[mode].session = await session.clone();
}

replWindows[mode].panel.reveal(vscode.ViewColumn.Two, preserveFocus);
return replWindows[mode];
}

export async function createReplWindow(session: NReplSession, mode: "clj" | "cljs" = "clj") {
const nreplClient = session.client;

if (replWindows[mode]) {
const modeSession = nreplClient.sessions[replWindows[mode].session.sessionId];
if (!modeSession || modeSession !== session) {
replWindows[mode].session = await session.clone();
}
replWindows[mode].panel.reveal(vscode.ViewColumn.Two, preserveFocus);
return replWindows[mode];
}

if (!session) {
vscode.window.showErrorMessage("Not connected to nREPL");
return;
}

const sessionClone = await session.clone();
let title = mode == "clj" ? "CLJ REPL" : "CLJS REPL";
const panel = vscode.window.createWebviewPanel("replInteractor",
title, {
viewColumn: vscode.ViewColumn.Two,
preserveFocus: preserveFocus
},
{
retainContextWhenHidden: true,
enableScripts: true, localResourceRoots: [vscode.Uri.file(path.join(ctx.extensionPath, 'html'))]
});
const panel = vscode.window.createWebviewPanel("replInteractor", title, {
viewColumn: vscode.ViewColumn.Two,
preserveFocus: true
}, {
retainContextWhenHidden: true,
enableScripts: true, localResourceRoots: [vscode.Uri.file(path.join(ctx.extensionPath, 'html'))]
});
const cljType: string = state.extensionContext.workspaceState.get('selectedCljTypeName');
const cljsType: string = state.extensionContext.workspaceState.get('selectedCljsTypeName');
let repl = replWindows[mode] = new REPLWindow(panel, sessionClone, mode, cljType, cljsType);
await repl.initialized;
return repl;
let replWin = replWindows[mode] = new REPLWindow(panel, sessionClone, mode, cljType, cljsType);
await replWin.initialized;
return replWin;
}

function loadNamespaceCommand(reload = true) {
setREPLNamespace(util.getDocumentNamespace(), reload).catch(r => { console.error(r) });
async function loadNamespaceCommand(reload = true) {
await setREPLNamespace(util.getDocumentNamespace(), reload).catch(r => { console.error(r) });
await openReplWindow(util.getREPLSessionType());
}

function setREPLNamespaceCommand() {
setREPLNamespace(util.getDocumentNamespace(), false).catch(r => { console.error(r) });
async function setREPLNamespaceCommand() {
await setREPLNamespace(util.getDocumentNamespace(), false).catch(r => { console.error(r) });
await openReplWindow(util.getREPLSessionType());
}

export async function sendTextToREPLWindow(text, ns: string, pprint: boolean) {
let wnd = await openReplWindow(util.getREPLSessionType());
let wnd = await openReplWindow(util.getREPLSessionType(), true);
if (wnd) {
let oldNs = wnd.ns;
if (ns && ns != oldNs)
Expand Down Expand Up @@ -307,8 +314,8 @@ function evalCurrentTopLevelFormInREPLWindowCommand() {

export function activate(context: vscode.ExtensionContext) {
ctx = context;
context.subscriptions.push(vscode.commands.registerCommand('calva.openCljReplWindow', () => openReplWindow("clj")));
context.subscriptions.push(vscode.commands.registerCommand('calva.openCljsReplWindow', () => openReplWindow("cljs")));
context.subscriptions.push(vscode.commands.registerCommand('calva.openCljReplWindow', () => openReplWindow("clj", true)));
context.subscriptions.push(vscode.commands.registerCommand('calva.openCljsReplWindow', () => openReplWindow("cljs"), true));
context.subscriptions.push(vscode.commands.registerCommand('calva.loadNamespace', loadNamespaceCommand));
context.subscriptions.push(vscode.commands.registerCommand('calva.setREPLNamespace', setREPLNamespaceCommand));
context.subscriptions.push(vscode.commands.registerCommand('calva.evalCurrentFormInREPLWindow', evalCurrentFormInREPLWindowCommand));
Expand Down
76 changes: 66 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Calva: Clojure & Clojurescript Interactive Programming",
"description": "Integrated REPL, formatter, Paredit, and more. Powered by nREPL.",
"icon": "assets/calva.png",
"version": "2.0.35",
"version": "2.0.36",
"publisher": "betterthantomorrow",
"author": {
"name": "Better Than Tomorrow",
Expand Down Expand Up @@ -222,7 +222,7 @@
"items": {
"type": "string"
}
},
},
"calva.replConnectSequences": {
"type": "array",
"description": "For when your project needs a custom REPL connect sequence.",
Expand Down Expand Up @@ -1144,7 +1144,7 @@
},
"scripts": {
"watch-webpack": "webpack --mode development --watch",
"watch-ts": "rm -rf ./out/* ./tsconfig.tsbuildinfo && npm run compile-cljs && tsc -watch -p ./tsconfig.json",
"watch-ts": "rimraf ./out && rimraf ./tsconfig.tsbuildinfo && npm run compile-cljs && tsc -watch -p ./tsconfig.json",
"release-cljs": "npx shadow-cljs release :calva-lib",
"NOT-USED-start": "ts-node --inspect=5858 webview-src/server/main.ts",
"NOT-USED-repl-window-dev-server": "concurrently \"npx nodemon -- ./webview-src/client/index.js\" \"npx webpack-dev-server\"",
Expand All @@ -1155,7 +1155,7 @@
"update-grammar": "node ./calva/calva-fmt/update-grammar.js ./calva/calva-fmt/atom-language-clojure/grammars/clojure.cson clojure.tmLanguage.json",
"release": "npm i && npm run update-grammar && npm run release-cljs && npm run webpack-release",
"disabled-release": "npm i && npm run update-grammar && npm run release-cljs && tsc -p ./",
"vscode:prepublish": "rm -rf ./out/* && npm run release",
"vscode:prepublish": "rimraf ./out && npm run release",
"disabled-vscode:prepublish": "npm run release",
"postinstall": "node ./node_modules/vscode/bin/install"
},
Expand Down Expand Up @@ -1207,6 +1207,7 @@
"webpack": "^4.33.0",
"webpack-cli": "^3.3.3",
"webpack-dev-server": "^3.8.0",
"vsce": "^1.66.0"
"vsce": "^1.66.0",
"rimraf": "^2.7.1"
}
}

0 comments on commit a433588

Please sign in to comment.