Skip to content

Commit

Permalink
Merge branch dev into published
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Feb 1, 2023
2 parents c2dbaff + e863e15 commit 3120917
Show file tree
Hide file tree
Showing 40 changed files with 8,781 additions and 200 deletions.
31 changes: 31 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,24 @@ jobs:
command: npm run integration-test
- store_test_results:
path: ~/calva/junit
test-vsix:
docker:
- image: cimg/clojure:1.11-browsers
working_directory: ~/calva
steps:
- attach_workspace:
at: /tmp
- run:
name: Restore build
command: rmdir ~/calva && cp -r /tmp/build ~/calva
- run:
name: Apt install missing dependencies
command: sudo apt update && sudo apt install -y libnss3
- run:
name: Run VSIX E2E Tests
command: npm run vsix-test /tmp/artifacts/calva-$(node -p 'require("./package.json").version').vsix
- store_test_results:
path: ~/calva/junit
github-release:
docker:
- image: cibuilds/github:0.10
Expand Down Expand Up @@ -428,6 +446,9 @@ workflows:
- test-integration:
requires:
- build
- test-vsix:
requires:
- build
- test-ts-unit:
requires:
- build
Expand All @@ -438,6 +459,7 @@ workflows:
- test-grammar
- test-cljslib
- test-integration
- test-vsix
- test-ts-unit
filters:
branches:
Expand Down Expand Up @@ -499,6 +521,14 @@ workflows:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+-?.*/
- test-vsix:
requires:
- build
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+-?.*/
- test-ts-unit:
requires:
- build
Expand All @@ -514,6 +544,7 @@ workflows:
- test-grammar
- test-cljslib
- test-integration
- test-vsix
- test-ts-unit
filters:
branches:
Expand Down
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ Changes to Calva.

## [Unreleased]

- [Sort aliases for deps.edn projects](https://github.com/BetterThanTomorrow/calva/issues/2035)
## [2.0.329] - 2023-02-01

## [2.0.327] - 2023-01-26
- [Sort aliases for deps.edn projects](https://github.com/BetterThanTomorrow/calva/issues/2035)
- [Sort pre-selected project at the top in REPL connect menu](https://github.com/BetterThanTomorrow/calva/issues/2043)
- Fix: [Indenter and formatter not in agreement about some forms](https://github.com/BetterThanTomorrow/calva/issues/2032)
- Fix: [Regressions introduced with clojure-lsp multi-project support in 2.0.327](https://github.com/BetterThanTomorrow/calva/issues/2041)
- Fix: [Can't use add require feature after updating to 2.0.327 version](https://github.com/BetterThanTomorrow/calva/issues/2040)
- Fix: [Formatting issues on backspace](https://github.com/BetterThanTomorrow/calva/issues/2038)
- Calva development: [Test the built VSIX extension in CI](https://github.com/BetterThanTomorrow/calva/issues/2051)
- Calva development, Fix: [We build Calva twice in CI](https://github.com/BetterThanTomorrow/calva/issues/2052)

## [2.0.328] - 2023-01-27
- Rollback of 2.0.327, first part of: [Regressions introduced with clojure-lsp multi-project support in 2.0.327](https://github.com/BetterThanTomorrow/calva/issues/2041)

## [2.0.327] - 2023-01-27

- [LSP support for multi-project and multi-workspace](https://github.com/BetterThanTomorrow/calva/pull/2020)
- Fix: [Clojure-lsp caching in multi-project workspace](https://github.com/BetterThanTomorrow/calva/issues/934)
Expand Down
58 changes: 56 additions & 2 deletions package-lock.json

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

12 changes: 10 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 cider-nrepl and clojure-lsp.",
"icon": "assets/calva.png",
"version": "2.0.327",
"version": "2.0.329",
"publisher": "betterthantomorrow",
"author": {
"name": "Better Than Tomorrow",
Expand Down Expand Up @@ -54,6 +54,7 @@
],
"activationEvents": [
"onLanguage:clojure",
"onCommand:calva.activateCalva",
"onCommand:calva.startStandaloneRepl",
"onCommand:calva.startStandaloneHelloRepl",
"onCommand:calva.startStandaloneCljsBrowserRepl",
Expand Down Expand Up @@ -941,6 +942,11 @@
}
],
"commands": [
{
"command": "calva.activateCalva",
"title": "Activate the Calva Extension",
"category": "Calva"
},
{
"command": "calva.startJoyrideReplAndConnect",
"title": "Start Joyride REPL and Connect",
Expand Down Expand Up @@ -2875,14 +2881,15 @@
"watch-cljs": "npx shadow-cljs watch :calva-lib :test",
"watch-ts-with-strict-nulls": "npx tsc --watch --project ./tsconfig.json --strictNullChecks",
"release-cljs": "npx shadow-cljs release :calva-lib :test",
"release": "npm i && npm run clean && npm run update-grammar && npm run release-cljs && webpack --mode production",
"release": "webpack --mode production",
"prerelease": "npm run precompile && npm run release-cljs",
"compile-test": "tsc -p ./",
"postrelease": "",
"vscode:prepublish": "npm run release",
"bump-version": "npm set git-tag-version false && npm version patch",
"calva-lib-test": "node ./out/cljs-lib/test/cljs-lib-tests.js",
"integration-test": "node ./out/extension-test/integration/runTests.js",
"vsix-test": "node ./vsix-test/launch.js",
"unit-test": "npx mocha --require ts-node/register 'src/extension-test/unit/**/*-test.ts'",
"unit-test-watch": "npx mocha --watch --require ts-node/register --watch-extensions ts --watch-files src 'src/extension-test/unit/**/*-test.ts'",
"prettier-format": "npx prettier --write \"./**/*.{ts,js,json}\"",
Expand Down Expand Up @@ -2932,6 +2939,7 @@
"@types/vscode": "^1.67.0",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"@vscode/test-electron": "^2.2.2",
"chai": "^4.2.0",
"concurrently": "^6.3.0",
"cson-parser": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/calva-fmt/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RangeEditProvider } from './providers/range_formatter';
import * as formatter from './format';
import * as inferer from './infer';
import * as docmirror from '../../doc-mirror/index';
import * as config from './config';
import * as config from '../../formatter-config';
import * as calvaConfig from '../../config';

function getLanguageConfiguration(): vscode.LanguageConfiguration {
Expand Down
25 changes: 25 additions & 0 deletions src/calva-fmt/src/format-index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { formatTextAtIdx, formatTextAtIdxOnType, jsify } from '../../../out/cljs-lib/cljs-lib';

export function formatIndex(
allText: string,
range: [number, number],
index: number,
eol: string,
onType: boolean = false,
config = {}
): { 'range-text': string; range: number[]; 'new-index': number; idx: number } {
const d = {
'all-text': allText,
idx: index,
eol,
range,
config,
};
const result = jsify((onType ? formatTextAtIdxOnType : formatTextAtIdx)(d));
if (!result['error']) {
return result;
} else {
console.error('Error in `formatIndex`:', result['error']);
throw result['error'];
}
}
39 changes: 5 additions & 34 deletions src/calva-fmt/src/format.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import * as vscode from 'vscode';
import * as config from './config';
import * as config from '../../formatter-config';
import * as outputWindow from '../../results-output/results-doc';
import {
getIndent,
getDocumentOffset,
MirroredDocument,
getDocument,
} from '../../doc-mirror/index';
import {
formatTextAtRange,
formatTextAtIdx,
formatTextAtIdxOnType,
formatText,
cljify,
jsify,
} from '../../../out/cljs-lib/cljs-lib';
import { formatTextAtRange, formatText, jsify } from '../../../out/cljs-lib/cljs-lib';
import * as util from '../../utilities';
import { isUndefined, cloneDeep } from 'lodash';
import { LispTokenCursor } from '../../cursor-doc/token-cursor';
import { formatIndex } from './format-index';

const FormatDepthDefaults = {
deftype: 2,
Expand Down Expand Up @@ -112,13 +106,14 @@ export async function formatPositionInfo(
'range-text': string;
range: number[];
'new-index': number;
} = await _formatIndex(
} = formatIndex(
doc.getText(),
formatRange,
index,
_convertEolNumToStringNotation(doc.eol),
onType,
{
...(await config.getConfig()),
...extraConfig,
'comment-form?': cursor.getFunctionName() === 'comment',
}
Expand Down Expand Up @@ -234,30 +229,6 @@ export async function formatCode(code: string, eol: number) {
}
}

async function _formatIndex(
allText: string,
range: [number, number],
index: number,
eol: string,
onType: boolean = false,
extraConfig = {}
): Promise<{ 'range-text': string; range: number[]; 'new-index': number }> {
const d = {
'all-text': allText,
idx: index,
eol: eol,
range: range,
config: { ...(await config.getConfig()), ...extraConfig },
};
const result = jsify(onType ? formatTextAtIdxOnType(d) : formatTextAtIdx(d));
if (!result['error']) {
return result;
} else {
console.error('Error in `_formatIndex`:', result['error']);
throw result['error'];
}
}

async function _formatRange(
rangeText: string,
allText: string,
Expand Down
2 changes: 1 addition & 1 deletion src/calva-fmt/src/providers/ontype_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EditableDocument } from '../../../cursor-doc/model';
import * as paredit from '../../../cursor-doc/paredit';
import { getConfig } from '../../../config';
import * as util from '../../../utilities';
import * as formatterConfig from '../config';
import * as formatterConfig from '../../../formatter-config';

export class FormatOnTypeEditProvider implements vscode.OnTypeFormattingEditProvider {
async provideOnTypeFormattingEdits(
Expand Down
44 changes: 44 additions & 0 deletions src/cursor-doc/backspace-on-whitespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { FormatterConfig } from '../formatter-config';
import { getIndent } from './indent';
import { EditableDocument } from './model';
import { LispTokenCursor } from './token-cursor';

export function backspaceOnWhitespace(
doc: EditableDocument,
cursor: LispTokenCursor,
config?: FormatterConfig
) {
const origIndent = getIndent(doc.model, cursor.offsetStart, config);
const onCloseToken = cursor.getToken().type === 'close';
let start = doc.selection.anchor;
let token = cursor.getToken();
if (token.type === 'ws') {
start = cursor.offsetEnd;
}
cursor.previous();
const prevToken = cursor.getToken();
if (prevToken.type === 'ws' && start === cursor.offsetEnd) {
token = prevToken;
}

let end = start;
if (token.type === 'ws') {
end = cursor.offsetStart;
cursor.previous();
if (cursor.getToken().type === 'eol') {
end = cursor.offsetStart;
cursor.previous();
if (cursor.getToken().type === 'ws') {
end = cursor.offsetStart;
cursor.previous();
}
}
}

const destTokenType = cursor.getToken().type;
let indent = destTokenType === 'eol' ? origIndent : 1;
if (destTokenType === 'open' || onCloseToken) {
indent = 0;
}
return { start, end, indent };
}
Loading

0 comments on commit 3120917

Please sign in to comment.