Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Move Clojure Warrior into Calva #362

Merged
merged 56 commits into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
781fd8d
initial
tonsky Dec 18, 2017
f947fc1
README
tonsky Dec 18, 2017
631cd0e
icon
tonsky Dec 18, 2017
4e4c375
wording
tonsky Dec 18, 2017
8d5a95c
add clojure keyword
tonsky Dec 18, 2017
5bf06d1
0.1.1 Some configuration options
tonsky Dec 20, 2017
ac4bc06
0.1.2 bracket pairs highlighting
tonsky Dec 21, 2017
25e7fe5
icons
tonsky Dec 21, 2017
2ed5838
trigger matchPairs after 16ms timeout
tonsky Dec 22, 2017
60f178d
match brackets when selection is not empty too
tonsky Dec 22, 2017
4be4c23
jump to matching bracket commands
tonsky Dec 22, 2017
48baa8b
reset editor.matchBrackets to default when returning to non-clojure e…
tonsky Dec 22, 2017
50accf1
Only trigger on config changes that are related to Clojure Warrior
tonsky Dec 22, 2017
7277eb1
0.1.3
tonsky Dec 22, 2017
3ea982d
0.1.4 More distinct rainbow colors, plays nice with dark theme
tonsky Dec 24, 2017
40a4861
don’t show matched brackets inside selection (closes #4)
tonsky Dec 27, 2017
0bbb2bb
Do not alter config dynamically (closes #3)
tonsky Dec 27, 2017
410db8f
Showing matching bracket immediately since it’s fast (closes #5)
tonsky Dec 27, 2017
86f0475
Jump to match should scroll if needed (closes #2)
tonsky Dec 27, 2017
7c264b9
0.1.5
tonsky Dec 27, 2017
66fe0e7
0.1.6 Avoid bracket styles bleeding into text typed next to them
tonsky Dec 27, 2017
0b9f3c8
nrepl proxy
tonsky Feb 23, 2018
67b9bb1
show mismatched brackets on scrollbar
greg-kargin Oct 7, 2018
44b2ef8
0.1.7
tonsky Oct 7, 2018
6ee85d0
Colorize ligatures #{ #( #_(
Dec 13, 2018
c0bd6e2
Remove binary
Dec 13, 2018
10bb94b
Fix pair bracket matching
Jan 3, 2019
8acc5a8
0.1.8 Highlight and match compound brackets: `#()`, `#{}`, `#?()`, `#…
tonsky Jan 4, 2019
ddabdcb
transparent bg on icon
tonsky Jan 4, 2019
bd8d004
added enableBracketColors, handle empty bracketColors, settings chang…
tonsky Jul 1, 2019
394c18e
bump vscode to 1.1.35
tonsky Jul 1, 2019
c5380e1
0.2.1 Removed `configurationDefault` as it was conflicting with Calva…
tonsky Jul 4, 2019
4da43e9
Dim `(comment)` forms
PEZ Jul 8, 2019
2ded9b6
Make comment form stylyng configurable
PEZ Jul 8, 2019
3c1e0bf
Handle commen form style ”comment” a tad better
PEZ Jul 8, 2019
e81ad5e
Free all the commentFormStyles
PEZ Jul 8, 2019
56859f4
Decorate ignore forms
PEZ Jul 9, 2019
b923162
Move defaults to package.json
tonsky Jul 10, 2019
1324100
0.2.2 Comment decoration (#14 by @PEZ)
tonsky Jul 10, 2019
9813520
0.2.3 Do not merge defaults for `commentFormStyle` and `ignoredFormSt…
tonsky Jul 10, 2019
8a4ab49
Fix ignore for some non-plain list
PEZ Jul 11, 2019
6caa911
Remove redundant \n from regexp
PEZ Jul 11, 2019
87fd9db
Fixed trailing whitespace in comment, symbols with word comment in th…
tonsky Jul 12, 2019
fd3e263
Prepare for merging into Calva as a subdirectory
PEZ Sep 30, 2019
497b89f
Move Clojure Warrior source code into Calva
PEZ Sep 30, 2019
334aab5
Use Calva's ClojureWarrior instead of extension
PEZ Sep 30, 2019
a527357
Tidy up CW extension installed error message
PEZ Sep 30, 2019
4b271ae
Clean away (now) redundant files
PEZ Sep 30, 2019
cc3c82d
Add launch config for extras test data
PEZ Sep 30, 2019
057363c
Update README to include Clojure Warrior info
PEZ Sep 30, 2019
8a8b874
Typo
PEZ Sep 30, 2019
952787d
Add CW insourcing to changelog
PEZ Sep 30, 2019
e54d242
Format comment form w/ italic as default
PEZ Sep 30, 2019
66d18ce
Remove unused imports and variables
PEZ Oct 1, 2019
e57dbc6
Rename Ckojure Warrior to Calva Highlight
PEZ Oct 1, 2019
100696e
Fix bug with highlight reading the wrong config
PEZ Oct 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,26 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
"--extensionDevelopmentPath=${workspaceRoot}",
],
"stopOnEntry": false,
"sourceMaps": true,
"env": {
"CALVA_DEV_GA": "FUBAR-69796730-4",
"DEBUG": "no-debug-universal-analytics"
},
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
},
{
"name": "Launch w/ test folder",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"${workspaceFolder}/test-data"
],
"stopOnEntry": false,
"sourceMaps": true,
Expand All @@ -22,5 +41,6 @@
"${workspaceFolder}/dist/**/*.js"
]
}

]
}
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ Changes to Calva.
## When time allows, this will be worked on
- [Support for custom project/workflow commands](https://github.com/BetterThanTomorrow/calva/issues/281)

## Being distilled

## [Unreleased]
- [Insourcing @tonsky's Clojue Warrior, now named Calva Highlight](https://github.com/BetterThanTomorrow/calva/pull/362)
- [Update status bar when configuration changed](https://github.com/BetterThanTomorrow/calva/issues/358)

## [2.0.42] - 29.09.2019
Expand Down
32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ When something doesn't work and you think there might be a workaround for it, pl
## Features

### At a glance
- Syntax highlighting, plus:
- Rainbow parens
- Highlights misplaced brackets
- LISP friendly bracket matching
- Ignore form (`#_`) dimming and `(comment)` form highlighting
- Clojure code formatting
- Quickly and easily get your REPL connected
- Evaluate code inline
- Run tests
Expand Down Expand Up @@ -112,19 +118,27 @@ To make slurping and barfing forward really easy to perform they are bound to `c

![Disable Mission Control Shortcuts](/assets/mission-control-shortcuts.gif)

### Conflicting with Parinfer extension
## Calva Highlight

There have been reports of the Parinfer extension and Calva not working too well together. You might to some extent get away with switching off Calva's formatting as-you-type, but also you might not. With Calva it is probably better to learn to use Paredit **slurp** and **barf** and generally rely on Calva's automatic formatting.
Calva takes care of syntax highlighting, and also provides some features not available through VS Code's highlighting mechanism. These extras inclode rainbow parens, sane bracket matching, and comment form dimming/highlighting.

You are in charge of how brackets and comments are highlighted:

## Clojure Warrior included
| Setting | Meaning | Example |
| --- | ------- | ------- |
| `"calva.highlight.enableBracketColors"` | Enable rainbow colors | `true` |
| `"calva.highlight.bracketColors"` | Which colors to use | `["#000", "#999"]` |
| `"calva.highlight.cycleBracketColors"` | Whether same colors should be reused for deeply nested brackets | `true` |
| `"calva.highlight.misplacedBracketStyle"` | Style of misplaced bracket | `{ "border": "2px solid #c33" }` |
| `"calva.highlight.matchedBracketStyle"` | Style of bracket pair highlight | `{"backgroundColor": "#E0E0E0"}` |
| `"calva.highlight.ignoredFormStyle"` | Style of `#_...` form | `{"textDecoration": "none; opacity: 0.5"}` |
| `"calva.highlight.commentFormStyle"` | Style of `(comment ...)` form | `{"fontStyle": "italic"}` |

This extension bundles [@tonsky](https://tonsky.me)'s [Clojure Warrior](https://marketplace.visualstudio.com/items?itemName=tonsky.clojure-warrior). Bringing you, amongst other things, rainbow parens and sane bracket matching.
Calva Highlight is built from **Clojure Warrior**, created by [Nikita Prokopov, a.k.a. @tonsky](https://tonsky.me)'s.

Note: If you for some reason do not want rainbow colors, put this in your `settings.json`:
## Conflicting with Parinfer extension

```json
"clojureWarrior.enableBracketColors": false
```
There have been reports of the Parinfer extension and Calva not working too well together. You might to some extent get away with switching off Calva's formatting as-you-type, but also you might not. With Calva it is probably better to learn to use Paredit **slurp** and **barf** and generally rely on Calva's automatic formatting.

## How to contribute

Expand All @@ -136,7 +150,7 @@ Calva is built using a combination of TypeScript and ClojureScript. The ClojureS

Many people have contributed to Calva. Here are the ones who have engaged in the project as such.

## Current Maintainers:
### Current Maintainers:

* [Peter Strömberg](https://github.com/PEZ)
* [Kevin Stehn](https://github.com/kstehn)
Expand Down
Binary file added assets/cw_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions calva/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from 'vscode';
import * as paredit from "./paredit/extension";
import * as fmt from "./calva-fmt/ts/extension";
import * as highlight from "./highlight/src/extension";
import * as state from './state';
import * as jackIn from './nrepl/jack-in';
import * as util from './utilities'
Expand Down Expand Up @@ -69,6 +70,8 @@ function activate(context: vscode.ExtensionContext) {
const legacyExtension = vscode.extensions.getExtension('cospaia.clojure4vscode'),
fmtExtension = vscode.extensions.getExtension('cospaia.calva-fmt'),
pareEditExtension = vscode.extensions.getExtension('cospaia.paredit-revived'),
cwExtension = vscode.extensions.getExtension('tonsky.clojure-warrior'),
cwConfig = vscode.workspace.getConfiguration('clojureWarrior'),
customCljsRepl = state.config().customCljsRepl,
replConnectSequences = state.config().replConnectSequences,
BUTTON_GOTO_WIKI = "Open the Wiki",
Expand Down Expand Up @@ -216,6 +219,19 @@ function activate(context: vscode.ExtensionContext) {
chan.appendLine("Default keybinding for Jack-in: ctrl+alt+c ctrl+alt+j");
state.analytics().logPath("/activated").logEvent("LifeCycle", "Activated").send();

if (!cwExtension) {
highlight.activate(context);
} else {
vscode.window.showErrorMessage("Clojure Warrior extension detected. Please uninstall it before continuing to use Calva.", ...["Got it.","Will do!"]);
}

for (const config of ["enableBracketColors", "bracketColors", "cycleBracketColors", "misplacedBracketStyle", "matchedBracketStyle", "commentFormStyle", "ignoredFormStyle"]) {
if (cwConfig.get(config) !== undefined) {
vscode.window.showWarningMessage("Legacy Clojure Warrior settings detected. These settings have changed prefix/namespace to from `clojureWarrior´ to `calva.highlight`. You should update `settings.json`.", ...["Roger that!"]);
break;
}
}

return {
hasParedit: true,
hasFormatter: true
Expand Down
70 changes: 70 additions & 0 deletions calva/highlight/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 0.2.4 - July 12, 2019

- Fixed trailing whitespace in comment, symbols with word comment in them (#15, #17)

# 0.2.3 - July 10, 2019

- Do not merge defaults for `commentFormStyle` and `ignoredFormStyle`

# 0.2.2 - July 10, 2019

- Comment decoration (#14 by @PEZ)

# 0.2.1 - July 4, 2019

- Removed `configurationDefault` as it was conflicting with Calva (#13)

# 0.2.0

- Option to disable rainbow brackets `clojureWarrior.enableBracketColors` (#12)
- Handle setting `clojureWarrior.bracketColors` to empty array (#12)
- Handle config changes when done from Setting GUI
- Disable default `editor.matchBrackets` for Clojure files

# 0.1.8

- Highlight and match compound brackets: `#()`, `#{}`, `#?()`, `#?@()` (#10, thx @maratynsky)

# 0.1.7

- Show mismatched brackets on scrollbar (#7, #8)

# 0.1.6

- Avoid bracket styles bleeding into text typed next to them

# 0.1.5

- Don’t show matched brackets inside selection (#4)
- Do not alter `editor.matchBrackets` in config dynamically (#3)
- Showing matching bracket immediately since it’s fast (#5)
- Jump to match should scroll if needed (#2)

# 0.1.4

- More distinct rainbow colors by default
- Default settings support both dark and light themes

# 0.1.3

- New command: `clojureWarrior.jumpToMatchingBracket`
- New command: `clojureWarrior.selectToMatchingBracket`
- `editor.matchBrackets` is set to false only for Clojure editors
- `matchPairs` is scheduled asynchronously not to slow down text editing

# 0.1.2

- Highlight bracket pairs
- Added config param: `"clojureWarrior.matchedBracketStyle": {"backgroundColor": "#E0E0E0"}`

# 0.1.1

Added configuration parameters:
- `"clojureWarrior.bracketColors": ["#000", "#999", ...]`
- `"clojureWarrior.cycleBracketColors": true`
- `"clojureWarrior.misplacedBracketStyle": { "border": "2px solid #c33" }`

# 0.1.0

- Initial release
- Rainbow Brackets
21 changes: 21 additions & 0 deletions calva/highlight/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Nikita Prokopov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
81 changes: 81 additions & 0 deletions calva/highlight/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Clojure Warrior

<img src="https://raw.githubusercontent.com/tonsky/clojure-warrior/master/extras/icon.png" width="128px" height="128px">

Visual Studio Code extension for Clojure development

## Features

Rainbow brackets:

- Chooses bracket color based on nesting level
- Distinct bracket colors, plays well with [Alabaster theme](https://marketplace.visualstudio.com/items?itemName=tonsky.theme-alabaster)
- Properly handles strings, comments and escaped characters
- Highlights misplaced brackets

Bracket pair matching:

- Higlights corresponding bracket pair to the one under the cursor
- Considers bracket directon and cursor position relative to it
- Only highlights pair when cursor is standing _outside_ the expression (right after the closed bracket or right before opening one)

Jump to matching bracket commands:

- Jump to corresponding bracket pair (same rules as in bracket pair matching): `clojureWarrior.jumpToMatchingBracket`
- Select a region between cursor and matching bracket (including brackets): `clojureWarrior.selectToMatchingBracket`

![Screenshot](https://raw.githubusercontent.com/tonsky/clojure-warrior/master/extras/screenshot.png)

## Configuration

| Key | Meaning | Example |
| --- | ------- | ------- |
| `"clojureWarrior.enableBracketColors"` | Enable rainbow colors | `true` |
| `"clojureWarrior.bracketColors"` | Which colors to use | `["#000", "#999"]` |
| `"clojureWarrior.cycleBracketColors"` | Whether same colors should be reused for deeply nested brackets | `true` |
| `"clojureWarrior.misplacedBracketStyle"` | Style of misplaced bracket | `{ "border": "2px solid #c33" }` |
| `"clojureWarrior.matchedBracketStyle"` | Style of bracket pair highlight | `{"backgroundColor": "#E0E0E0"}` |
| `"clojureWarrior.commentFormStyle"` | Style of `(comment ...)` form | `{"textDecoration": "none; opacity: 0.5"}` |
| `"clojureWarrior.ignoredFormStyle"` | Style of `#_...` form | `{"textDecoration": "none; opacity: 0.5"}` |

To disable VS Code default bracket matching for Clojure files, add this to `settings.json`:

```
"[clojure]": {
"editor.matchBrackets": false
}
```

## Installation

1. Go to `Extensions`
2. Search for `Clojure Warrior`
3. Install
4. Restart Visual Studio Code (or click `Reload window`)
5. Open a Clojure/ClojureScript/EDN file

## Workign on Clojure Warrior

Compiling:

```
cd clojure-warrior
npm install
npm run watch
```

Installing dev version locally:

```
ln -s `pwd` ~/.vscode/extensions/tonsky.clojure-warrior-0.2.0
```

Publishing:

```
vsce publish
```

## License

[MIT License](https://github.com/tonsky/clojure-warrior/blob/master/./LICENSE.txt)
Loading