import { linter, type Diagnostic } from '@codemirror/lint' import { Shrimp } from '#/index' import { CompilerError } from '#compiler/compilerError' export const createShrimpDiagnostics = (shrimp: Shrimp) => linter((view) => { const code = view.state.doc.toString() const diagnostics: Diagnostic[] = [] try { shrimp.parse(code) } catch (err) { if (err instanceof CompilerError) { diagnostics.push({ from: err.from, to: err.to, severity: 'error', message: err.message, }) } } return diagnostics })