Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

479 B
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */
import type { CompletionSource } from "@codemirror/autocomplete";
import type { EditorState } from "@codemirror/state";

/**
 * Condition CompletionSource
 */
export function conditionalCompletion(opts: {
  completion: CompletionSource;
  predicate: (state: EditorState) => boolean;
}): CompletionSource {
  return (ctx) => {
    if (!opts.predicate(ctx.state)) {
      return null;
    }
    return opts.completion(ctx);
  };
}