Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 14 additions & 9 deletions bun.lock

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

46 changes: 34 additions & 12 deletions package-lock.json

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

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"ws": "^8.21.3"
},
"dependencies": {
"@acode.app/canvas-view": "^0.0.1",
"@codemirror/autocomplete": "^6.20.3",
"@codemirror/commands": "^6.11.0",
"@codemirror/lang-angular": "^0.1.4",
Expand All @@ -148,15 +149,15 @@
"@codemirror/lang-wast": "^6.0.2",
"@codemirror/lang-xml": "^6.1.0",
"@codemirror/lang-yaml": "^6.1.3",
"@codemirror/language": "^6.12.4",
"@codemirror/language": "^6.13.1",
"@codemirror/language-data": "^6.5.2",
"@codemirror/legacy-modes": "^6.5.3",
"@codemirror/lint": "^6.9.7",
"@codemirror/lsp-client": "file:codemirror-lsp-client",
"@codemirror/search": "^6.7.1",
"@codemirror/state": "^6.7.1",
"@codemirror/state": "^6.7.6",
"@codemirror/theme-one-dark": "^6.1.3",
"@codemirror/view": "^6.43.9",
"@codemirror/view": "^6.43.14",
"@deadlyjack/ajax": "^1.2.6",
"@emmetio/codemirror6-plugin": "^0.4.1",
"@lezer/common": "^1.5.4",
Expand Down Expand Up @@ -207,11 +208,11 @@
"overrides": {
"@codemirror/autocomplete": "^6.20.3",
"@codemirror/commands": "^6.11.0",
"@codemirror/language": "^6.12.4",
"@codemirror/language": "^6.13.1",
"@codemirror/lint": "^6.9.7",
"@codemirror/search": "^6.7.1",
"@codemirror/state": "^6.7.1",
"@codemirror/view": "^6.43.9",
"@codemirror/state": "^6.7.6",
"@codemirror/view": "^6.43.14",
"@lezer/common": "^1.5.4",
"@lezer/lr": "^1.4.10",
"tar": "^7.5.22"
Expand Down
35 changes: 29 additions & 6 deletions src/cm/baseExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { history } from "@codemirror/commands";
import {
bracketMatching,
codeFolding as codeFoldingState,
defaultHighlightStyle,
foldGutter,
indentOnInput,
Expand All @@ -31,6 +32,17 @@ import indentationFolding from "./indentationFolding";
export interface BaseExtensionOptions {
autoIndent?: boolean;
codeFolding?: boolean;
/**
* Show CodeMirror's fold gutter with code folding. The canvas renderer
* draws its own fold markers, so it only needs the folding state.
*/
foldGutter?: boolean;
/**
* The canvas renderer draws the selection, cursors, drop cursor, active
* line (and its gutter) and special characters itself, so those
* extensions are left out.
*/
canvas?: boolean;
autoCloseBrackets?: boolean;
bracketMatching?: boolean;
highlightActiveLine?: boolean;
Expand All @@ -46,17 +58,26 @@ export default function createBaseExtensions(
const {
autoIndent = true,
codeFolding = true,
foldGutter: showFoldGutter = true,
canvas = false,
autoCloseBrackets = true,
bracketMatching: enableBracketMatching = true,
highlightActiveLine: enableHighlightActiveLine = true,
highlightSelectionMatches: enableHighlightSelectionMatches = true,
} = options;
const extensions: Extension[] = [highlightSpecialChars(), history()];
const extensions: Extension[] = [history()];
if (!canvas) extensions.push(highlightSpecialChars());

if (enableHighlightActiveLine) extensions.push(highlightActiveLineGutter());
if (codeFolding) extensions.push(foldGutter(), indentationFolding);
extensions.push(drawSelection());
extensions.push(dropCursor());
if (enableHighlightActiveLine && !canvas) {
extensions.push(highlightActiveLineGutter());
}
if (codeFolding) {
extensions.push(
showFoldGutter ? foldGutter() : codeFoldingState(),
indentationFolding,
);
}
if (!canvas) extensions.push(drawSelection(), dropCursor());
extensions.push(EditorState.allowMultipleSelections.of(true));
if (autoIndent) extensions.push(indentOnInput());
extensions.push(
Expand All @@ -66,7 +87,9 @@ export default function createBaseExtensions(
if (autoCloseBrackets) extensions.push(closeBrackets());
extensions.push(rectangularSelection());
extensions.push(crosshairCursor());
if (enableHighlightActiveLine) extensions.push(highlightActiveLine());
if (enableHighlightActiveLine && !canvas) {
extensions.push(highlightActiveLine());
}
if (enableHighlightSelectionMatches) {
extensions.push(highlightSelectionMatches());
}
Expand Down
Loading
Loading