Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Apr 25, 2020
2 parents 148856e + 22c38e5 commit 133ad6c
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 20 deletions.
31 changes: 30 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"mochaExplorer.files": "src/extension-test/unit/**/*-test.ts",
"mochaExplorer.require": "ts-node/register",
"cSpell.words": [
"Batsov",
"Bozhidar",
"Calva's",
"Dedent",
"Docstring",
"Girardi",
"Hmmm",
"Insourcing",
"Jackin",
Expand All @@ -17,40 +20,54 @@
"Sexp",
"Sexpr",
"Sexps",
"Strömberg's",
"VSIX",
"ahlbrecht",
"analysing",
"autoindent",
"betterthantomorrow",
"bhauman",
"borkdude",
"brear",
"calva",
"cljc",
"cljfmt",
"cljfx",
"clojurians",
"cmdline",
"debugadapter",
"defproject",
"defun",
"deref",
"derefed",
"derefs",
"devtools",
"eckstein",
"enablement",
"errored",
"eval",
"falsesomething",
"fehse",
"feldman",
"figwheel",
"filipe",
"fipp",
"hacky",
"highlightning",
"hopperdietzel",
"howto",
"isequal",
"janne",
"jszip",
"junit",
"keywordize",
"klepsch",
"kondo",
"lein",
"leiningen",
"lexing",
"luminus",
"mkdocs",
"nashorn",
"niclas",
"nrepl",
Expand All @@ -61,15 +78,27 @@
"piggieback",
"postrelease",
"pprint",
"preinstall",
"prepending",
"prewatch",
"ringe",
"sauvala",
"scaturro",
"schäfer",
"sivertsen",
"stian",
"strömberg",
"suitible",
"terje",
"togglemode",
"tonsky",
"tonsky's",
"truesomething",
"tsbuildinfo",
"udris",
"ullrich",
"vsce",
"zprint"
"zprint",
"être"
]
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changes to Calva.

## [Unreleased]

## [2.0.95] - 2020-04-25
- [Separate setting for highlighting current indent guide](https://github.com/BetterThanTomorrow/calva/issues/625)
- [Fix: Problems with v2.0.94 rendering performance ](https://github.com/BetterThanTomorrow/calva/issues/626)

## [2.0.94] - 2020-04-24
- [Rainbow indent guides](https://github.com/BetterThanTomorrow/calva/issues/620)

Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Go to the [documentation](https://calva.io/) to find info on how to connect Calv

* Syntax highlighting, plus:
* Rainbow parens
* Rainbow indent guides
* Highlight active indent guide
* Highlights misplaced brackets
* LISP friendly bracket matching
* Ignore form (`#_`) dimming and `(comment)` form highlighting
Expand All @@ -44,7 +46,7 @@ Go to the [documentation](https://calva.io/) to find info on how to connect Calv
* [Linting](https://calva.io/linting/)
* Intellisense
* Go to / Peek at definition
* View docstrings on hover
* View doc strings on hover
* View function signatures on hover, including help with knowing which argument you are typing
* [Debugger](https://calva.io/debugger/)
* Support for [Clojure tools/deps](https://clojure.org/guides/deps_and_cli), [Leiningen](https://leiningen.org), [shadow-cljs](http://shadow-cljs.org), [lein-figwheel](https://github.com/bhauman/lein-figwheel), and [Figwheel Main](https://figwheel.org), and Nashorn repls. (For [Boot](https://boot-clj.com), only Connect scenarios work, there is no Jack-in yet.)
Expand All @@ -70,6 +72,10 @@ It is pretty educational using the signature help hover to see which argument yo

![Signature Help](assets/howto/signature-help.gif)

### Demo: Syntax highlighting, rainbow parens and guides

![Dimming ignored forms](/assets/howto/rainbow-guides.gif)

### Demo: Syntax highlighting, dimming ignored forms

![Dimming ignored forms](/assets/howto/dimming-ignores.gif)
Expand All @@ -89,7 +95,7 @@ I'm glad you are reading this section! There are many ways and you are welcome t
* Give us feedback.
* Via [#calva](https://clojurians.slack.com/messages/calva/) at the Clojurians Slack.
* Via filing issues.
* Fix issues. PRs welcome! Calva is built using a combination of TypeScript and ClojureScript. The ClojureScript part uses the [shadow-cljs](http://shadow-cljs.org) toolchain. See the [How to Contribute](https://github.com/BetterThanTomorrow/calva/wiki/How-to-Contribute) page on the wiki for instructions on how to hack on Calva. TL;DR _It is super easy to get started!_
* Fix issues. PRs welcome! Calva is built using a combination of TypeScript and ClojureScript. The ClojureScript part uses the [shadow-cljs](http://shadow-cljs.org) tool chain. See the [How to Contribute](https://github.com/BetterThanTomorrow/calva/wiki/How-to-Contribute) page on the wiki for instructions on how to hack on Calva. TL;DR _It is super easy to get started!_
* Fix typos. In the UI and in the docs. It might seem like a small enough thing to not bother about it, but really, typos get in the way of comprehension. Typos are bad, uhm?
* Become a GitHub sponsor. Read on.

Expand Down Expand Up @@ -134,7 +140,7 @@ We are Clojure and Visual Studio Code fans who care about the ergonomics of usin
### Current Maintainers

* [Peter Strömberg](https://github.com/PEZ)
* [Kevin Stehn](https://github.com/kstehn)
* [Kevin Ahlbrecht](https://github.com/kstehn)
* [Christian Fehse](https://github.com/cfehse)
* [Brandon Ringe](https://github.com/bpringe)

Expand Down
Binary file added assets/howto/rainbow-guides.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package-lock.json

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

10 changes: 8 additions & 2 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.95",
"version": "2.0.96",
"publisher": "betterthantomorrow",
"author": {
"name": "Better Than Tomorrow",
Expand Down Expand Up @@ -562,10 +562,16 @@
},
"calva.highlight.rainbowIndentGuides": {
"type": "boolean",
"default": true,
"default": false,
"description": "Use rainbow indent guides. (To use built-in indent guides, disable this and enable built-in guides in [\"clojure\"] scope.",
"scope": "resource"
},
"calva.highlight.highlightActiveIndent": {
"type": "boolean",
"default": true,
"description": "Highlight active indent with a guideline. (Unlike the VS Code built-in setting, this works independently of the rainbowIndentGuides setting.)",
"scope": "resource"
},
"calva.highlight.bracketColors": {
"type": "array",
"items": {
Expand Down
50 changes: 37 additions & 13 deletions src/highlight/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function activate(context: vscode.ExtensionContext) {
ignoredFormType: vscode.TextEditorDecorationType,
enableBracketColors,
useRainbowIndentGuides,
highlightActiveIndent,
pairsBack: Map<string, [Range, Range]> = new Map(),
pairsForward: Map<string, [Range, Range]> = new Map(),
placedGuidesColor: Map<string, number> = new Map(),
Expand All @@ -51,7 +52,9 @@ export function activate(context: vscode.ExtensionContext) {
vscode.window.onDidChangeTextEditorSelection(event => {
if (event.textEditor === vscode.window.activeTextEditor && is_clojure(event.textEditor)) {
matchPairs();
decorateActiveGuides();
if (highlightActiveIndent && rainbowTypes.length) {
decorateActiveGuides();
}
}
}, null, context.subscriptions);

Expand Down Expand Up @@ -180,6 +183,11 @@ export function activate(context: vscode.ExtensionContext) {
dirty = true;
}

if (highlightActiveIndent !== configuration.get<boolean>("highlightActiveIndent")) {
highlightActiveIndent = configuration.get<boolean>("highlightActiveIndent");
dirty = true;
}

if (useRainbowIndentGuides !== configuration.get<boolean>("rainbowIndentGuides")) {
useRainbowIndentGuides = configuration.get<boolean>("rainbowIndentGuides");
dirty = true;
Expand Down Expand Up @@ -221,6 +229,7 @@ export function activate(context: vscode.ExtensionContext) {
len = rainbowTypes.length,
colorsEnabled = enableBracketColors && len > 0,
guideColorsEnabled = useRainbowIndentGuides && len > 0,
activeGuideEnabled = highlightActiveIndent && len > 0,
colorIndex = cycleBracketColors ? (i => i % len) : (i => Math.min(i, len - 1));

let in_comment_form = false,
Expand Down Expand Up @@ -331,7 +340,7 @@ export function activate(context: vscode.ExtensionContext) {
if (colorsEnabled) {
rainbow[colorIndex(stack_depth)].push(decoration);
}
if (guideColorsEnabled) {
if (guideColorsEnabled || activeGuideEnabled) {
const matchPos = pos.translate(0, 1);
const openSelection = matchBefore(new vscode.Selection(matchPos, matchPos));
const openSelectionPos = openSelection[0].start;
Expand All @@ -348,13 +357,17 @@ export function activate(context: vscode.ExtensionContext) {

for (var i = 0; i < rainbowTypes.length; ++i) {
activeEditor.setDecorations(rainbowTypes[i], rainbow[i]);
activeEditor.setDecorations(rainbowGuidesTypes[i], rainbowGuides[i]);
if (guideColorsEnabled) {
activeEditor.setDecorations(rainbowGuidesTypes[i], rainbowGuides[i]);
}
}
activeEditor.setDecorations(misplacedType, misplaced);
activeEditor.setDecorations(commentFormType, comment_forms);
activeEditor.setDecorations(ignoredFormType, ignores);
matchPairs();
decorateActiveGuides();
if (activeGuideEnabled) {
decorateActiveGuides();
}
}

function matchBefore(selection) {
Expand Down Expand Up @@ -413,20 +426,31 @@ export function activate(context: vscode.ExtensionContext) {
const doc = activeEditor.document;
const mirrorDoc = docMirror.getDocument(doc);
const cursor = mirrorDoc.getTokenCursor(doc.offsetAt(selection.start));
let visitedEndPositions = [selection.start];
findActiveGuide:
while (cursor.forwardList() && cursor.upList()) {
const endPos = doc.positionAt(cursor.offsetStart);
for (let i = 0; i < visitedEndPositions.length; i++) {
if (endPos.isEqual(visitedEndPositions[i])) {
break findActiveGuide;
}
}
visitedEndPositions.push(endPos);
cursor.backwardSexp();
const downCursor = cursor.clone();
downCursor.downList();
const startPos = doc.positionAt(downCursor.offsetStart - 1);
const guideRange = new vscode.Range(startPos, endPos);
let colorIndex;
colorIndex = placedGuidesColor.get(position_str(startPos));
if (colorIndex !== undefined) {
if (guideRange.contains(selection)) {
decorateGuide(doc, startPos, endPos, activeGuides);
activeEditor.setDecorations(activeGuidesTypes[colorIndex], activeGuides);
if (downCursor.downList()) {
const startPos = doc.positionAt(downCursor.offsetStart - 1);
const guideRange = new vscode.Range(startPos, endPos);
let colorIndex;
colorIndex = placedGuidesColor.get(position_str(startPos));
if (colorIndex !== undefined) {
if (guideRange.contains(selection)) {
decorateGuide(doc, startPos, endPos, activeGuides);
activeEditor.setDecorations(activeGuidesTypes[colorIndex], activeGuides);
}
break;
}
} else {
break;
}
}
Expand Down

0 comments on commit 133ad6c

Please sign in to comment.