This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
StateField, | |
StateEffect, | |
EditorSelection, | |
StateEffectType, | |
} from '@codemirror/state' | |
import { EditorView, ViewPlugin } from '@codemirror/view' | |
/** @import { Text, Line } from '@codemirror/state' */ | |
/** @import { PluginValue, BlockInfo } from '@codemirror/view' */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { minimalSetup } from 'codemirror' | |
import { EditorState } from '@codemirror/state' | |
import { EditorView, keymap } from '@codemirror/view' | |
import { insertNewlineAndIndent, insertBlankLine } from '@codemirror/commands' | |
function removeNewlineCommands(exts) { | |
const newlineCommands = [insertNewlineAndIndent, insertBlankLine] | |
return exts.map(ext => { | |
if (ext?.facet == keymap) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { basicSetup, minimalSetup } from 'codemirror' | |
import { Prec } from '@codemirror/state' | |
import { EditorView, keymap, placeholder } from '@codemirror/view' | |
import { search, findNext, findPrevious } from '@codemirror/search' | |
const SearchPanel = (() => { | |
const searchConfigFacet = search({})[0].facet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@top JSONDiff { section* } | |
value { True | False | Null | Number | String | Object | Array } | |
section { | |
Header | |
(Deletion+ Insertion* | Insertion+) | |
} | |
Header { "@" "[" list<path> "]" "\n" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {basicSetup} from 'codemirror' | |
import { | |
autocompletion, | |
completionStatus, | |
setSelectedCompletion, | |
currentCompletions, | |
selectedCompletionIndex, | |
moveCompletionSelection, | |
closeBrackets, | |
} from '@codemirror/autocomplete' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// These settings override both User and Default settings for the JavaScript syntax | |
{ | |
"auto_complete_selector": "meta.tag, comment.block.documentation, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc", | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { foldService } from '@codemirror/language' | |
/** @param {string} text */ | |
function indentLevel(text) { | |
const mat = /** @type {RegExpMatchArray} */ ( | |
text.match(/^( *)([^ ]?)/)) | |
return mat[2] ? mat[1].length : -1 | |
} | |
export const foldByIndentation = foldService.of(({ doc }, from, _to) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { EditorState, Text } from '@codemirror/state' | |
import { changeTracker, lineStatistics, commit } from './lib/codemirror/experiments.js' | |
/** @typedef {{ len: number, count: number }} LineStat */ | |
function countSurrogates(/** @type {string} */ s) { | |
const regex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g | |
let n = 0 | |
while (regex.exec(s)) n++ | |
return n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Given chunks as iov, truncate the prompt if possible. | |
* @param {string[]} chunks | |
* @param {string} prompt | |
*/ | |
function truncatePrompt(chunks, prompt) { | |
/** Does the iov start with the given prefix? Return the end position [x, y] if yes, null if no. | |
* @param {string[]} chunks | |
* @param {string} target | |
*/ | |
function chunksStartWithPrefix(chunks, target) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function byCallbacks(s0, inp) { | |
if (inp == null) { | |
let s = s0 | |
if (s0.integerPart === '') { | |
s = { ...s0, integerPart: '0' } | |
} | |
return s.integerPart + (s.decimalPart ? `.${s.decimalPart}` : '') | |
} if (s0.readingIntegerPart) { | |
if (inp === '.') { |
NewerOlder