Skip to content

feat(cli): add TUI REPL with syntax highlighting #2

@eddmann

Description

@eddmann

Summary

Add an interactive TUI (terminal user interface) REPL for santa-lang with enhanced editing and visualization features.

Description

Create a terminal-based REPL that goes beyond a simple line-by-line input, providing a rich interactive environment for exploring and experimenting with santa-lang code.

Proposed Features

Enhanced Input

  • Multi-line editing with proper cursor movement
  • Syntax highlighting as you type
  • Auto-indentation for blocks and nested expressions
  • Parenthesis/bracket matching and highlighting
  • History navigation with search (Ctrl+R)

Auto-completion

  • Built-in function names
  • User-defined variables and functions in scope
  • Keyword completion (let, match, if, etc.)

Output Display

  • Pretty-printed results with syntax highlighting
  • Truncated output for large data structures with expand option
  • Type information display (optional)

Additional Features

  • :help command for built-in documentation
  • :type <expr> to show expression type
  • :clear to reset the environment
  • :load <file> to load and evaluate a file
  • :save <file> to save session history

Example Session

santa> let numbers = [1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]

santa> numbers
  |> map(|x| x * 2)
  |> filter(|x| x > 4)
[6, 8, 10]

santa> :type numbers
List<Integer>

santa> :help map
map(fn, list) - Transforms each element in a list using the provided function

Implementation Considerations

  • Use a TUI library (e.g., ratatui for Rust, blessed/ink for Node)
  • Maintain REPL state/environment across inputs
  • Handle Ctrl+C gracefully (cancel current input, not exit)
  • Support terminal resizing
  • Consider vi/emacs keybinding modes

References

  • ipython - Enhanced Python REPL
  • evcxr - Rust REPL with rich features
  • nushell - Modern shell with TUI features

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions