Skip to content

Commit

Permalink
v.2.0.0 of extension finished
Browse files Browse the repository at this point in the history
  • Loading branch information
sivertsenstian committed Feb 15, 2018
1 parent 6187e9f commit 891a88c
Show file tree
Hide file tree
Showing 19 changed files with 1,450 additions and 1,210 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
# Change Log
All notable changes to the "visual:clojure" extension will be documented in this file.

## [2.0.0] - 15.02.2018
- Relase of v2.0
- Major rewrite of codebase
- Added support for:
- Formatting clj and cljs using cljfmt
- Linting clj and cljs using joker
- No longer using nrepl/cider for errors as this proved unreliable and troublesome to parse
- Auto-connect, and reconnect using .nrepl-port file in project
- Reworked keybindings, using prefix `alt+v` command
- `alt+v c` connect
- `alt+v r` reconnect
- `alt+v l` lint file
- `alt+v e` eval sexp / selection
- `alt+v enter` eval file
- Improved hover and signature markdown / apperance
- Added immutable and cursor for more sane state-management

## [Pre-releases]

## [0.0.2] - 11.03.2017
Expand All @@ -17,7 +34,7 @@ All notable changes to the "visual:clojure" extension will be documented in this
### Added
* Most of the basic functionality now kinda works for both clj and cljs
* Connect to existing nREPL and determine if it is running a cljs-session. Default shortcut: alt+c
* Supports and stores both cljs and clj sessions, using the appropriate one for ops based on file-extension
* Supports and stores both cljs and clj sessions, using the appropriate one for ops based on file-extension
* cljs -> cljs-session
* clj and cljc -> clj-session
* Evaluate file from command (automatically on open, save, and change). Default shortcut: alt+f5
Expand Down
1,216 changes: 868 additions & 348 deletions package-lock.json

Large diffs are not rendered by default.

77 changes: 28 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "visual:clojure",
"description": "Clojure and ClojureScript support",
"icon": "assets/icon.png",
"version": "1.0.1",
"version": "2.0.0",
"publisher": "stiansivertsen",
"author": {
"name": "Stian Sivertsen",
Expand All @@ -18,7 +18,8 @@
},
"categories": [
"Languages",
"Snippets",
"Linters",
"Formatters",
"Other"
],
"activationEvents": [
Expand All @@ -30,20 +31,20 @@
"type": "object",
"title": "Parinfer",
"properties": {
"visualclojure.formatOnSave": {
"clojure.format.enable": {
"type": "boolean",
"default": true,
"description": "Run cljfmt when opening a new file and on file save"
"description": "Enable/disable cljfmt as clojure formatter."
},
"visualclojure.refreshOnSave": {
"visualclojure.evalOnSave": {
"type": "boolean",
"default": true,
"description": "Run ns-refresh when opening a new file and on file save"
"description": "Run load-file when opening a new file and on file save"
},
"visualclojure.evalOnSave": {
"visualclojure.lintOnSave": {
"type": "boolean",
"default": true,
"description": "Run load-file when opening a new file and on file save"
"description": "Run joker-linting when opening a new file and on file save"
},
"visualclojure.autoConnect": {
"type": "boolean",
Expand Down Expand Up @@ -74,71 +75,49 @@
"category": "visualclojure"
},
{
"command": "visualclojure.toggleSession",
"title": "toggle session",
"category": "visualclojure"
},
{
"command": "visualclojure.refresh",
"title": "refresh: changed files",
"category": "visualclojure"
},
{
"command": "visualclojure.refreshAll",
"title": "refresh: all files (in dependency order)",
"category": "visualclojure"
},
{
"command": "visualclojure.refreshClear",
"title": "refresh: clear",
"category": "visualclojure"
},
{
"command": "visualclojure.formatDocument",
"title": "format: current file",
"command": "visualclojure.lintFile",
"title": "lint current file",
"category": "visualclojure"
}
],
"snippets": [
{
"language": "clojure",
"path": "./snippets/clojure.json"
}
],
"keybindings": [
{
"command": "visualclojure.connect",
"key": "alt+c",
"mac": "alt+c"
"key": "alt+v c",
"mac": "alt+v c"
},
{
"command": "visualclojure.reconnect",
"key": "alt+v r",
"mac": "alt+v r"
},
{
"command": "visualclojure.evaluateSelection",
"key": "alt+Enter",
"mac": "alt+Enter"
"key": "alt+v e",
"mac": "alt+v e"
},
{
"command": "visualclojure.evaluateFile",
"key": "alt+f5",
"mac": "alt+f5"
"key": "alt+v enter",
"mac": "alt+v enter"
},
{
"command": "visualclojure.lintFile",
"key": "alt+v l",
"mac": "alt+v l"
}
]
},
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"bencode": "1.0.0",
"buffer": "^5.0.7",
"bencoder": "0.0.5",
"find": "0.2.7",
"immutable": "3.8.1",
"immutable-cursor": "2.0.1",
"jszip": "3.1.3",
"lodash": "4.17.4",
"net": "1.0.2",
"node-cmd": "^3.0.0",
"socket.io-client": "^2.0.4",
"stream": "0.0.2",
"util": "0.10.3",
"vscode": "^1.1.4"
}
}
41 changes: 0 additions & 41 deletions snippets/clojure.json

This file was deleted.

99 changes: 49 additions & 50 deletions src/connector.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const vscode = require('vscode');
const find = require('find');
const fs = require('fs');
const state = require ('./state');
const state = require('./state');
const statusbar = require('./statusbar');
const repl = require('./repl/client');
const message = require('./repl/message');

function connectToHost (hostname, port) {
let client = repl.create({hostname, port}).once('connect', function () {
function connectToHost(hostname, port) {
let client = repl.create({
hostname,
port
}).once('connect', function () {
state.cursor.set("connected", true);
let msg = message.listSessions();
client.send(msg, function (results) {
Expand All @@ -20,47 +23,45 @@ function connectToHost (hostname, port) {
function findSession(session, sessions) {
let current = state.deref();
let client = repl.create()
.once('connect', function () {
let msg = message.testSession(sessions[session]);
client.send(msg, function (results) {
for (var i = 0; i < results.length; i++) {
let result = results[i];
if (result.value && result.value === "3.14") {
state.cursor.set("cljs", sessions[session]);
} else if (result.ex) {
.once('connect', function () {
let msg = message.testSession(sessions[session]);
client.send(msg, function (results) {
for (var i = 0; i < results.length; i++) {
let result = results[i];
if (result.value && result.value === "3.14" && current.get("cljs") === null) {
state.cursor.set("cljs", sessions[session]);
} else if (result.ex && current.get("clj") === null) {
state.cursor.set("clj", sessions[session]);
}
}
client.end();
});
})
.once('end', function () {
//If last session, check if found
if (session === (sessions.length - 1) && current.get("cljs") === null) {
//Default to first session if no cljs-session is found, and treat it as a clj-session
if (sessions.length > 0) {
state.cursor.set("clj", sessions[session]);
}
} else if ((session + 1) <= (sessions.length - 1) &&
(current.get("cljs") === null || current.get("clj") === null)) {
findSession((session + 1), sessions);
} else {
//Check the initial file where the command is called from
//TODO FIXME -clojureEvaluation.evaluateFile(state);
}
client.end();
statusbar.update();
});
})
.once('end', function () {
//If last session, check if found
if (session === (sessions.length - 1) && current.get("cljs") === null) {
//Default to first session if no cljs-session is found, and treat it as a clj-session
if (sessions.length > 0) {
state.cursor.set("clj", sessions[session]);
}
} else if (current.get("cljs") === null || current.get("clj") === null) {
findSession((session + 1), sessions);
} else {
//Check the initial file where the command is called from
//TODO FIXME -clojureEvaluation.evaluateFile(state);
}
statusbar.update();
});
};

function connect() {
let current = state.deref(),
path = vscode.workspace.rootPath,
hostname = "localhost",
port = null;
let path = vscode.workspace.rootPath;
new Promise((resolve, reject) => {
find.file(/\.nrepl-port$/, path, (files) => {
if(files.length > 0) {
if (files.length > 0) {
fs.readFile(files[0], 'utf8', (err, data) => {
if(!err) {
if (!err) {
resolve(data);
} else {
reject("");
Expand All @@ -72,17 +73,17 @@ function connect() {
});
}).then((port) => {
vscode.window.showInputBox({
placeHolder: "Enter existing nREPL hostname:port here...",
prompt: "Add port to nREPL if localhost, otherwise 'hostname:port'",
value: "localhost:" + port,
ignoreFocusOut: true
})
.then(function(url) {
let [hostname, port] = url.split(':');
state.cursor.set("hostname", hostname);
state.cursor.set("port", port);
connectToHost(hostname, port);
});
placeHolder: "Enter existing nREPL hostname:port here...",
prompt: "Add port to nREPL if localhost, otherwise 'hostname:port'",
value: "localhost:" + port,
ignoreFocusOut: true
})
.then(function (url) {
let [hostname, port] = url.split(':');
state.cursor.set("hostname", hostname);
state.cursor.set("port", port);
connectToHost(hostname, port);
});
});
};

Expand All @@ -92,14 +93,12 @@ function reconnect() {
};

function autoConnect() {
let path = vscode.workspace.rootPath,
port = null
current = state.deref();;
let path = vscode.workspace.rootPath;
return new Promise((resolve, _) => {
find.file(/\.nrepl-port$/, path, (files) => {
if(files.length > 0) {
if (files.length > 0) {
fs.readFile(files[0], 'utf8', (err, data) => {
if(!err) {
if (!err) {
let hostname = "localhost",
port = parseFloat(data);

Expand Down
Loading

0 comments on commit 891a88c

Please sign in to comment.