From 671d87e5f14cc465631074446b3164fcaf1e4839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Mon, 21 Oct 2024 19:00:42 +0000 Subject: [PATCH 01/12] Bring on version 2.0.481! --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3e6f8b4f8..1391133c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "calva", - "version": "2.0.480", + "version": "2.0.481", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "calva", - "version": "2.0.480", + "version": "2.0.481", "license": "MIT", "dependencies": { "@vscode/debugadapter": "^1.64.0", diff --git a/package.json b/package.json index ec7c5185c..00c23ca96 100644 --- a/package.json +++ b/package.json @@ -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.480", + "version": "2.0.481", "publisher": "betterthantomorrow", "author": { "name": "Better Than Tomorrow", From 1d152aa13e98fc536405e8db03b58dda290bc56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Sat, 26 Oct 2024 19:29:41 -0400 Subject: [PATCH 02/12] Add when contexts for ns, replType and projectRoot * Fixes #2652 --- CHANGELOG.md | 2 ++ docs/site/when-clauses.md | 4 +++- src/state.ts | 2 ++ src/when-contexts.ts | 7 +++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63a896bbc..8502c2945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Changes to Calva. ## [Unreleased] +- [Add extension when contexts for Calva states such as project root, session type, ns](https://github.com/BetterThanTomorrow/calva/issues/2652) + ## [2.0.480] - 2024-10-21 - Fix: [Custom command snippets use the wrong ns when repl sessions types do not match](https://github.com/BetterThanTomorrow/calva/issues/2653) diff --git a/docs/site/when-clauses.md b/docs/site/when-clauses.md index 9b6174a51..b1d2f63ef 100644 --- a/docs/site/when-clauses.md +++ b/docs/site/when-clauses.md @@ -19,4 +19,6 @@ description: Calva comes with batteries included and preconfigured, and if you d * `calva:cursorAfterComment`: `true` when the cursor is adjacent after a line comment * `calva:cursorAtStartOfLine`: `true` when the cursor is at the start of a line including any leading whitespace * `calva:cursorAtEndOfLine`: `true` when the cursor is at the end of a line including any trailing whitespace - +* `calva:projectRoot`: A string with the absolute path to the repl project root +* `calva:ns`: A string with the current namespace +* `calva:replSessionType`: `clj`, or `cljs` depending on the file type of the current file diff --git a/src/state.ts b/src/state.ts index 6e319f71b..12d1b1c1c 100644 --- a/src/state.ts +++ b/src/state.ts @@ -202,6 +202,8 @@ export async function initProjectDir( ); } if (projectRootPath) { + console.log('Setting project root to: ', projectRootPath.fsPath); + void vscode.commands.executeCommand('setContext', 'calva:projectRoot', projectRootPath.fsPath); setStateValue(PROJECT_DIR_KEY, projectRootPath.fsPath); setStateValue(PROJECT_DIR_URI_KEY, projectRootPath); return projectRootPath; diff --git a/src/when-contexts.ts b/src/when-contexts.ts index 94a2e81f7..f2556979b 100644 --- a/src/when-contexts.ts +++ b/src/when-contexts.ts @@ -3,6 +3,9 @@ import { deepEqual } from './util/object'; import * as docMirror from './doc-mirror'; import * as context from './cursor-doc/cursor-context'; import * as util from './utilities'; +import * as namespace from './namespace'; +import * as session from './nrepl/repl-session'; +import { cljsLib } from './utilities'; export let lastContexts: context.CursorContext[] = []; export let currentContexts: context.CursorContext[] = []; @@ -18,6 +21,10 @@ export function setCursorContextIfChanged(editor: vscode.TextEditor) { } const contexts = determineCursorContexts(editor.document, editor.selections[0].active); setCursorContexts(contexts); + const [ns, _form] = namespace.getDocumentNamespace(editor.document); + void vscode.commands.executeCommand('setContext', 'calva:ns', ns); + const sessionType = session.getReplSessionType(cljsLib.getStateValue('connected')); + void vscode.commands.executeCommand('setContext', 'calva:replSessionType', sessionType); } function determineCursorContexts( From a7727b53650b2ebd98ac08b54163e021717e6b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Sun, 27 Oct 2024 20:18:20 +0100 Subject: [PATCH 03/12] Clarify non-trailing slash in projectRoot path --- docs/site/when-clauses.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/site/when-clauses.md b/docs/site/when-clauses.md index b1d2f63ef..870b30925 100644 --- a/docs/site/when-clauses.md +++ b/docs/site/when-clauses.md @@ -19,6 +19,6 @@ description: Calva comes with batteries included and preconfigured, and if you d * `calva:cursorAfterComment`: `true` when the cursor is adjacent after a line comment * `calva:cursorAtStartOfLine`: `true` when the cursor is at the start of a line including any leading whitespace * `calva:cursorAtEndOfLine`: `true` when the cursor is at the end of a line including any trailing whitespace -* `calva:projectRoot`: A string with the absolute path to the repl project root +* `calva:projectRoot`: A string with the absolute path to the repl project root, _without trailing slash_ * `calva:ns`: A string with the current namespace * `calva:replSessionType`: `clj`, or `cljs` depending on the file type of the current file From 611678453f78a236a75d4537b6befa9a72748975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Mon, 28 Oct 2024 23:40:07 +0100 Subject: [PATCH 04/12] Remove option to skip ignored forms moving backwards by sexp Fixes #2657 --- CHANGELOG.md | 1 + src/cursor-doc/token-cursor.ts | 15 +++++---------- src/cursor-doc/utilities.ts | 2 +- .../unit/cursor-doc/token-cursor-test.ts | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8502c2945..3bc0cb523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Changes to Calva. ## [Unreleased] - [Add extension when contexts for Calva states such as project root, session type, ns](https://github.com/BetterThanTomorrow/calva/issues/2652) +- Fix: [Calva internals: The `backwardSexp` can't handle skipping ignored forms, even though it says it can](https://github.com/BetterThanTomorrow/calva/issues/2657) ## [2.0.480] - 2024-10-21 diff --git a/src/cursor-doc/token-cursor.ts b/src/cursor-doc/token-cursor.ts index f4e91b041..caf3e87fd 100644 --- a/src/cursor-doc/token-cursor.ts +++ b/src/cursor-doc/token-cursor.ts @@ -316,12 +316,7 @@ export class LispTokenCursor extends TokenCursor { * * @returns true if the cursor was moved, false otherwise. */ - backwardSexp( - skipComments = true, - skipMetadata = false, - skipIgnoredForms = false, - skipReaders = true - ) { + backwardSexp(skipComments = true, skipMetadata = false, skipReaders = true) { const stack = []; this.backwardWhitespace(skipComments); if (this.getPrevToken().type === 'open') { @@ -345,9 +340,9 @@ export class LispTokenCursor extends TokenCursor { } if (skipMetadata) { const metaCursor = this.clone(); - metaCursor.backwardSexp(true, false, false, false); + metaCursor.backwardSexp(true, false, false); if (metaCursor.tokenBeginsMetadata()) { - this.backwardSexp(skipComments, skipMetadata, skipIgnoredForms); + this.backwardSexp(skipComments, skipMetadata, skipReaders); } } if (skipReaders) { @@ -376,9 +371,9 @@ export class LispTokenCursor extends TokenCursor { } if (skipMetadata) { const metaCursor = this.clone(); - metaCursor.backwardSexp(true, false, false, false); + metaCursor.backwardSexp(true, false, false); if (metaCursor.tokenBeginsMetadata()) { - this.backwardSexp(skipComments, skipMetadata, skipIgnoredForms); + this.backwardSexp(skipComments, skipMetadata, skipReaders); } } if (skipReaders) { diff --git a/src/cursor-doc/utilities.ts b/src/cursor-doc/utilities.ts index 00cafdb03..b2c110e4a 100644 --- a/src/cursor-doc/utilities.ts +++ b/src/cursor-doc/utilities.ts @@ -41,7 +41,7 @@ export function isRightSexpStructural(cursor: LispTokenCursor): boolean { return false; } cursor.forwardSexp(true, true, false); - cursor.backwardSexp(false, false, false, false); + cursor.backwardSexp(false, false, false); const token = cursor.getToken(); if (token.type === 'open') { diff --git a/src/extension-test/unit/cursor-doc/token-cursor-test.ts b/src/extension-test/unit/cursor-doc/token-cursor-test.ts index 9c2692180..b89cc9ab5 100644 --- a/src/extension-test/unit/cursor-doc/token-cursor-test.ts +++ b/src/extension-test/unit/cursor-doc/token-cursor-test.ts @@ -228,6 +228,20 @@ describe('Token Cursor', () => { cursor.backwardSexp(true, true); expect(cursor.offsetStart).toBe(b.selections[0].anchor); }); + it('Does not skip ignored forms if skipIgnoredForms', () => { + const a = docFromTextNotation('(a #_1 #_2 |3)'); + const b = docFromTextNotation('(a #_a #_|2 3)'); + const cursor = a.getTokenCursor(a.selections[0].anchor); + cursor.backwardSexp(true, true); + expect(cursor.offsetStart).toBe(b.selections[0].anchor); + }); + it('Does not skip stacked ignored forms', () => { + const a = docFromTextNotation('(a #_ #_ 1 2 |3)'); + const b = docFromTextNotation('(a #_ #_ 1 |2 3)'); + const cursor = a.getTokenCursor(a.selections[0].anchor); + cursor.backwardSexp(true, true); + expect(cursor.offsetStart).toBe(b.selections[0].anchor); + }); }); describe('downList', () => { From 6b6d8611bcae346cbd1235568d9ba3b31dc18407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 29 Oct 2024 21:12:17 +0100 Subject: [PATCH 05/12] Fix typo [skip ci] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bc0cb523..51bcba681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Changes to Calva. ## [Unreleased] - [Add extension when contexts for Calva states such as project root, session type, ns](https://github.com/BetterThanTomorrow/calva/issues/2652) -- Fix: [Calva internals: The `backwardSexp` can't handle skipping ignored forms, even though it says it can](https://github.com/BetterThanTomorrow/calva/issues/2657) +- Fix: [Calva internals: The `backwardSexp` function can't handle skipping ignored forms, even though it says it can](https://github.com/BetterThanTomorrow/calva/issues/2657) ## [2.0.480] - 2024-10-21 From 93def6bdb54139308dbca69a5c396d5c4b495175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 29 Oct 2024 21:21:47 +0100 Subject: [PATCH 06/12] Add test for making sure the ignore marker is not included in top level form selection * Fixes #2655 --- CHANGELOG.md | 1 + .../unit/cursor-doc/token-cursor-test.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51bcba681..f5a014b01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changes to Calva. - [Add extension when contexts for Calva states such as project root, session type, ns](https://github.com/BetterThanTomorrow/calva/issues/2652) - Fix: [Calva internals: The `backwardSexp` function can't handle skipping ignored forms, even though it says it can](https://github.com/BetterThanTomorrow/calva/issues/2657) +- Fix: [Keep support for evaluating top level form in ignored forms when at top level](https://github.com/BetterThanTomorrow/calva/issues/2655) ## [2.0.480] - 2024-10-21 diff --git a/src/extension-test/unit/cursor-doc/token-cursor-test.ts b/src/extension-test/unit/cursor-doc/token-cursor-test.ts index b89cc9ab5..2bd377d6e 100644 --- a/src/extension-test/unit/cursor-doc/token-cursor-test.ts +++ b/src/extension-test/unit/cursor-doc/token-cursor-test.ts @@ -804,6 +804,13 @@ describe('Token Cursor', () => { const cursor: LispTokenCursor = a.getTokenCursor(a.selections[0].active); expect(cursor.rangeForDefun(a.selections[0].active)).toEqual(textAndSelection(b)[1]); }); + // https://github.com/BetterThanTomorrow/calva/issues/2655 + it('Does not include ignore marker', () => { + const a = docFromTextNotation('a #_ [b (c|)] [d]'); + const b = docFromTextNotation('a #_ |[b (c)]| [d]'); + const cursor: LispTokenCursor = a.getTokenCursor(a.selections[0].active); + expect(cursor.rangeForDefun(a.selections[0].active)).toEqual(textAndSelection(b)[1]); + }); describe('Rich Comment Form top level context', () => { it('Finds range for a top level form inside a comment', () => { const a = docFromTextNotation('aaa (comment [bbb cc|c] ddd)'); @@ -954,6 +961,13 @@ describe('Token Cursor', () => { const cursor: LispTokenCursor = a.getTokenCursor(0); expect(cursor.rangeForDefun(a.selections[0].anchor)).toEqual(textAndSelection(b)[1]); }); + // https://github.com/BetterThanTomorrow/calva/issues/2655 + it('Does not include ignore marker', () => { + const a = docFromTextNotation('aaa (comment #_ [bbb ccc|] ddd)'); + const b = docFromTextNotation('aaa (comment #_ |[bbb ccc]| ddd)'); + const cursor: LispTokenCursor = a.getTokenCursor(a.selections[0].active); + expect(cursor.rangeForDefun(a.selections[0].active)).toEqual(textAndSelection(b)[1]); + }); }); }); From 4272c0cbdf92fd97ab3027a664462596320420e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 29 Oct 2024 22:06:19 +0100 Subject: [PATCH 07/12] Document the special treatment of ignored forms at the top level [skip ci] --- docs/site/evaluation.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/site/evaluation.md b/docs/site/evaluation.md index d2c29a4d0..53b295ebd 100644 --- a/docs/site/evaluation.md +++ b/docs/site/evaluation.md @@ -35,7 +35,7 @@ Some of the commands also let you choose what should happen with the results: * The `line` style is the default. * The `ignore` style will put an ignore marker (`#_`) before the result. * The `rcf` style will wrap the result in a rich comment form ( `(comment ...)`). - + Here are some example keybindings for using the different comment styles with the **Evaluate Top Level Form (defun) to Comment** command: ```jsonc @@ -108,6 +108,8 @@ The **current top-level form** means top-level in a structural sense. It is _not An ”exception” is introduced by the `comment` form. It will create a new top level context, so that any forms immediately inside a `(comment ...)` form will be considered top-level by Calva. This is to support a workflow with what is often referred to the [Rich Comments](rich-comments.md). +A special case is ignored forms (using the `#_` marker) at the top level. They will always be selected as top level forms separately from their ignore marker, enabling evaluating them as top level forms. Similar to Rich Comments. + At the top level the selection of which form is the current top level form follows the same rules as those for [the current form](#current-form). ### Evaluate Enclosing Form From 69a56452af48456697d41bc5fcf15354d1fecf78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 29 Oct 2024 22:01:19 +0100 Subject: [PATCH 08/12] Use separate style for top level ignored forms --- src/highlight/src/extension.ts | 62 ++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/src/highlight/src/extension.ts b/src/highlight/src/extension.ts index 77ed1d0b1..a5723e6c2 100755 --- a/src/highlight/src/extension.ts +++ b/src/highlight/src/extension.ts @@ -39,6 +39,8 @@ let lastHighlightedEditor, commentFormType: vscode.TextEditorDecorationType, ignoredFormStyle, ignoredFormType: vscode.TextEditorDecorationType, + ignoredTopLevelFormStyle, + ignoredTopLevelFormType: vscode.TextEditorDecorationType, enableBracketColors, useRainbowIndentGuides, highlightActiveIndent, @@ -152,6 +154,13 @@ function reset_styles() { } ignoredFormType = decorationType(ignoredFormStyle || { textDecoration: 'none; opacity: 0.5' }); + if (ignoredTopLevelFormType) { + activeEditor.setDecorations(ignoredTopLevelFormType, []); + } + ignoredTopLevelFormType = decorationType( + ignoredTopLevelFormStyle || ignoredFormStyle || { textDecoration: 'none; opacity: 0.5' } + ); + dirty = false; } @@ -206,6 +215,11 @@ function reloadConfig() { dirty = true; } + if (!isEqual(ignoredTopLevelFormStyle, configuration.get('ignoredTopLevelFormStyle'))) { + ignoredTopLevelFormStyle = configuration.get('ignoredTopLevelFormStyle'); + dirty = true; + } + if (dirty) { scheduleRainbowBrackets(); } @@ -231,18 +245,19 @@ function updateRainbowBrackets() { reset_styles(); } - const doc = activeEditor.document, - mirrorDoc = docMirror.getDocument(doc), - rainbow = rainbowTypes.map(() => []), - rainbowGuides = rainbowTypes.map(() => []), - misplaced = [], - comment_forms = [], - ignores = [], - 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); + const doc = activeEditor.document; + const mirrorDoc = docMirror.getDocument(doc); + const rainbow = rainbowTypes.map(() => []); + const rainbowGuides = rainbowTypes.map(() => []); + const misplaced = []; + const comment_forms = []; + const ignores = []; + const topLevelIgnores = []; + const len = rainbowTypes.length; + const colorsEnabled = enableBracketColors && len > 0; + const guideColorsEnabled = useRainbowIndentGuides && len > 0; + const activeGuideEnabled = highlightActiveIndent && len > 0; + const colorIndex = cycleBracketColors ? (i) => i % len : (i) => Math.min(i, len - 1); let in_comment_form = false; let stack_depth = 0; @@ -252,14 +267,14 @@ function updateRainbowBrackets() { placedGuidesColor = new Map(); activeEditor.visibleRanges.forEach((range) => { // Find the visible forms - const startOffset = doc.offsetAt(range.start), - endOffset = doc.offsetAt(range.end), - startCursor: LispTokenCursor = mirrorDoc.getTokenCursor(0), - startRange = startCursor.rangeForDefun(startOffset, false), - endCursor: LispTokenCursor = mirrorDoc.getTokenCursor(endOffset), - endRange = endCursor.rangeForDefun(endOffset, false), - rangeStart = startRange ? startRange[0] : startOffset, - rangeEnd = endRange ? endRange[1] : endOffset; + const startOffset = doc.offsetAt(range.start); + const endOffset = doc.offsetAt(range.end); + const startCursor: LispTokenCursor = mirrorDoc.getTokenCursor(0); + const startRange = startCursor.rangeForDefun(startOffset, false); + const endCursor: LispTokenCursor = mirrorDoc.getTokenCursor(endOffset); + const endRange = endCursor.rangeForDefun(endOffset, false); + const rangeStart = startRange ? startRange[0] : startOffset; + const rangeEnd = endRange ? endRange[1] : endOffset; // Look for top level ignores, and adjust starting point if found const topLevelSentinelCursor = mirrorDoc.getTokenCursor(rangeStart); let startPaintingFrom = rangeStart; @@ -299,7 +314,11 @@ function updateRainbowBrackets() { ignoreCursor.forwardSexp(true, true, true); } const ignore_end = activeEditor.document.positionAt(ignoreCursor.offsetStart); - ignores.push(new Range(ignore_start, ignore_end)); + if (cursor.atTopLevel()) { + topLevelIgnores.push(new Range(ignore_start, ignore_end)); + } else { + ignores.push(new Range(ignore_start, ignore_end)); + } } } const token = cursor.getToken(), @@ -399,6 +418,7 @@ function updateRainbowBrackets() { activeEditor.setDecorations(misplacedType, misplaced); activeEditor.setDecorations(commentFormType, comment_forms); activeEditor.setDecorations(ignoredFormType, ignores); + activeEditor.setDecorations(ignoredTopLevelFormType, topLevelIgnores); matchPairs(); if (activeGuideEnabled) { decorateActiveGuides(); From 44ae9fc53059ef3a402372cf9696c4ecbd8365eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 29 Oct 2024 22:59:40 +0100 Subject: [PATCH 09/12] Add configuration for `ignoredTopLevelForms` * Fixes #2660 --- docs/site/syntax-highlighting.md | 1 + package.json | 6 ++++++ test-data/.vscode/settings.json | 5 ++++- test-data/test-files/highlight_test.clj | 8 ++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/site/syntax-highlighting.md b/docs/site/syntax-highlighting.md index c85ebdafa..fbb6298b7 100644 --- a/docs/site/syntax-highlighting.md +++ b/docs/site/syntax-highlighting.md @@ -44,6 +44,7 @@ You are in charge of how brackets and comments are highlighted via the `calva.hi | `misplacedBracketStyle` | Style of misplaced bracket | `{ "border": "2px solid #c33" }` | | `matchedBracketStyle` | Style of bracket pair highlight | `{"backgroundColor": "#E0E0E0"}` | | `ignoredFormStyle` | Style of `#_...` form | `{"textDecoration": "none; opacity: 0.5"}` | +| `ignoredTopLevelFormStyle` | Style of `#_...` form. (If not set uses `ignoredFormStyle`) | `{ "textDecoration": "none; text-shadow: 2px 2px 5px rgba(255, 215, 0, 0.75)" }` | | `commentFormStyle` | Style of `(comment ...)` form | `{"fontStyle": "italic"}` | !!! Note "Calva disables the VS Code built-in indent guides" diff --git a/package.json b/package.json index 00c23ca96..b425e30ab 100644 --- a/package.json +++ b/package.json @@ -1142,6 +1142,12 @@ "default": null, "description": "Style of `#_` ignored forms", "scope": "resource" + }, + "calva.highlight.ignoredTopLevelFormStyle": { + "type": "object", + "default": null, + "markdownDescription": "Style of top level `#_` ignored forms. If not specified, it will be the same as what's set for `calva.highlight.ignoredFormStyle`", + "scope": "resource" } } } diff --git a/test-data/.vscode/settings.json b/test-data/.vscode/settings.json index 4c610fb24..f9cd699ae 100644 --- a/test-data/.vscode/settings.json +++ b/test-data/.vscode/settings.json @@ -139,5 +139,8 @@ "afterCL]ReplJackInCode": ["(println :hello)", "(println :world!)"], "cljsType": "none" } - ] + ], + "calva.highlight.ignoredTopLevelFormStyle": { + "textDecoration": "none; text-shadow: 2px 2px 5px rgba(255, 215, 0, 0.75)" + } } diff --git a/test-data/test-files/highlight_test.clj b/test-data/test-files/highlight_test.clj index 4ce8cd123..7f9489f73 100644 --- a/test-data/test-files/highlight_test.clj +++ b/test-data/test-files/highlight_test.clj @@ -22,7 +22,7 @@ ;; \ "()" ;; \ -;; +;; (((#((()))))) ([ #{ }()[]]) @@ -54,10 +54,10 @@ (println "I ❤️Clojure") ([{} () []])) - + (comment (+ (* 2 2) - 2) + 2) (Math/abs -1) (defn hello [s] (str "Hello " s)) @@ -143,7 +143,7 @@ bar [:c {:d :e}]] [:b [:c {:d :e}]]] -(comment +(comment (foo #_"bar" baz)) #_{:foo "foo" :bar (comment [["bar"]])} From 1302306595e1a548f0a2b59f1e9e289e09a1e506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 29 Oct 2024 23:07:52 +0100 Subject: [PATCH 10/12] Fix typo in documentation [skip ci] --- docs/site/syntax-highlighting.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/site/syntax-highlighting.md b/docs/site/syntax-highlighting.md index fbb6298b7..83f6cc41b 100644 --- a/docs/site/syntax-highlighting.md +++ b/docs/site/syntax-highlighting.md @@ -43,8 +43,8 @@ You are in charge of how brackets and comments are highlighted via the `calva.hi | `cycleBracketColors` | Whether same colors should be
reused for deeply nested brackets | `true` | | `misplacedBracketStyle` | Style of misplaced bracket | `{ "border": "2px solid #c33" }` | | `matchedBracketStyle` | Style of bracket pair highlight | `{"backgroundColor": "#E0E0E0"}` | -| `ignoredFormStyle` | Style of `#_...` form | `{"textDecoration": "none; opacity: 0.5"}` | -| `ignoredTopLevelFormStyle` | Style of `#_...` form. (If not set uses `ignoredFormStyle`) | `{ "textDecoration": "none; text-shadow: 2px 2px 5px rgba(255, 215, 0, 0.75)" }` | +| `ignoredFormStyle` | Style of `#_...` forms | `{"textDecoration": "none; opacity: 0.5"}` | +| `ignoredTopLevelFormStyle` | Style of `#_...` forms at the top level. (If not set, uses `ignoredFormStyle`) | `{ "textDecoration": "none; text-shadow: 2px 2px 5px rgba(255, 215, 0, 0.75)" }` | | `commentFormStyle` | Style of `(comment ...)` form | `{"fontStyle": "italic"}` | !!! Note "Calva disables the VS Code built-in indent guides" From eef974a9ba24dc1eb869fba73ab15a4178b9dd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 29 Oct 2024 23:13:17 +0100 Subject: [PATCH 11/12] Update changelog [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5a014b01..7e206a93f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Changes to Calva. - [Add extension when contexts for Calva states such as project root, session type, ns](https://github.com/BetterThanTomorrow/calva/issues/2652) - Fix: [Calva internals: The `backwardSexp` function can't handle skipping ignored forms, even though it says it can](https://github.com/BetterThanTomorrow/calva/issues/2657) - Fix: [Keep support for evaluating top level form in ignored forms when at top level](https://github.com/BetterThanTomorrow/calva/issues/2655) +- [Enable separate styling for top level ignored forms](https://github.com/BetterThanTomorrow/calva/issues/2660) ## [2.0.480] - 2024-10-21 From 28df841cd96902995efe9131f89d9bebbdb0336c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 29 Oct 2024 23:20:35 +0100 Subject: [PATCH 12/12] Add changelog section for v2.0.481 [skip ci] --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e206a93f..799a6c840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Changes to Calva. ## [Unreleased] +## [2.0.481] - 2024-10-29 + - [Add extension when contexts for Calva states such as project root, session type, ns](https://github.com/BetterThanTomorrow/calva/issues/2652) - Fix: [Calva internals: The `backwardSexp` function can't handle skipping ignored forms, even though it says it can](https://github.com/BetterThanTomorrow/calva/issues/2657) - Fix: [Keep support for evaluating top level form in ignored forms when at top level](https://github.com/BetterThanTomorrow/calva/issues/2655)