9ff4c0dbd5
* Setup project-wide prettier * Remove old workspace file * Remove old debugging directives * New top-level .prettierignore * Updated Prettier config settings * Contrubuting guide: Fix for some bad code blocks * Added more ignores * Improved the format script command * printWidth set to 100 * Formatted entire repo (pnpm run format)
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import {
|
|
highlightSpecialChars,
|
|
drawSelection,
|
|
highlightActiveLine,
|
|
dropCursor,
|
|
lineNumbers,
|
|
highlightActiveLineGutter,
|
|
keymap,
|
|
} from "@codemirror/view";
|
|
import type { Extension } from "@codemirror/state";
|
|
import { highlightSelectionMatches } from "@codemirror/search";
|
|
import { json as jsonLang } from "@codemirror/lang-json";
|
|
import { closeBrackets } from "@codemirror/autocomplete";
|
|
import { bracketMatching } from "@codemirror/language";
|
|
import { indentWithTab } from "@codemirror/commands";
|
|
|
|
export function getPreviewSetup(): Array<Extension> {
|
|
return [
|
|
jsonLang(),
|
|
highlightSpecialChars(),
|
|
drawSelection(),
|
|
dropCursor(),
|
|
bracketMatching(),
|
|
highlightSelectionMatches(),
|
|
lineNumbers(),
|
|
];
|
|
}
|
|
|
|
export function getViewerSetup(): Array<Extension> {
|
|
return [drawSelection(), dropCursor(), bracketMatching(), lineNumbers()];
|
|
}
|
|
|
|
export function getEditorSetup(showLineNumbers = true, showHighlights = true): Array<Extension> {
|
|
const options = [
|
|
drawSelection(),
|
|
dropCursor(),
|
|
bracketMatching(),
|
|
closeBrackets(),
|
|
keymap.of([indentWithTab]),
|
|
];
|
|
|
|
if (showLineNumbers) {
|
|
options.push(lineNumbers());
|
|
}
|
|
|
|
if (showHighlights) {
|
|
options.push([
|
|
highlightActiveLineGutter(),
|
|
highlightSpecialChars(),
|
|
highlightActiveLine(),
|
|
highlightSelectionMatches(),
|
|
]);
|
|
}
|
|
|
|
return options;
|
|
}
|