gpui-libghostty 0.3.0

Native libghostty terminal component for GPUI
docs.rs failed to build gpui-libghostty-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: gpui-libghostty-0.1.3

gpui-libghostty

Native Ghostty terminal and embedded Neovim components for GPUI.

Demo

Embedded Neovim editing this project's README with completion:

https://github.com/user-attachments/assets/140e3552-1074-4994-b91d-d0966fe623c9

Status

Project status is alpha, expect bugs and instability.

Crates

Published on crates.io: gpui-libghostty and gpui-neovim. Add either to your project:

cargo add gpui-libghostty
cargo add gpui-neovim
  • gpui-libghostty embeds a native Ghostty terminal in GPUI.
  • gpui-neovim embeds Neovim in GPUI.

Supports macOS and Linux with Wayland.

Requirements

  • Rust 1.95
  • macOS and Xcode command-line tools, or Wayland with EGL, libc++ 21 or newer, libxml2, and desktop OpenGL 4.3
  • Zig 0.16
  • Neovim for gpui-neovim

The default Nix development shell provides the Rust tools, Zig, Neovim, and the required Linux build and runtime libraries. macOS still requires Xcode command-line tools because the native build uses xcrun.

On Ubuntu 24.04, install libc++-21-dev and libc++abi-21-dev from LLVM's APT repository, plus libxml2-dev from Ubuntu.

Set ZIG to select a non-default Zig executable. Set GPUI_NVIM or assign NvimOptions::executable to select Neovim.

Terminal

[dependencies]
gpui-libghostty = "0.3"
use gpui_libghostty::TerminalOptions;

gpui_libghostty::bind_gpui!(gpui);

let terminal = Terminal::spawn(
    TerminalOptions::new("bash", project_directory),
    window,
    cx,
)?;

Terminal::spawn returns an Entity<Terminal> you can render as a GPUI child. To load the user's Ghostty configuration:

use gpui_libghostty::TerminalConfiguration;

let mut options = TerminalOptions::new("bash", project_directory);
options.configuration = TerminalConfiguration::UserDefault;

Clipboard approval

Clipboard operations requiring approval are denied unless clipboard_approval accepts them. Explicit Ghostty allow/deny settings still apply.

use std::sync::Arc;
use gpui_libghostty::ClipboardOperation;

// Example application policy: permit writes that Ghostty asks to confirm,
// but deny protected reads and unsafe pastes.
options.clipboard_approval = Some(Arc::new(|request| {
    request.operation == ClipboardOperation::Write
}));

NvimOptions::clipboard_approval exposes the same policy for embedded Neovim.

Neovim

use gpui_neovim::NvimOptions;

gpui_neovim::bind_gpui!(gpui);

let editor = NvimEditor::spawn(
    NvimOptions::new(project_directory, initial_file),
    window,
    cx,
)?;
let editor = cx.new(|_| editor);

Call and await NvimEditor::open_file through the entity to reuse the running Neovim instance.

Run the standalone example from this repository:

cargo run -p gpui-neovim --example neovim -- README.md

The optional argument is a file or directory. The example uses your Neovim configuration; install nvim on PATH or set GPUI_NVIM to its executable.

Checks

cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked

GPUI compatibility

Neither library depends on GPUI. bind_gpui! uses your application's GPUI crate or module path, including renamed packages such as gpui-pre.

Replace the old Terminal / NvimEditor imports with the bindings shown above. Invoke the binding once at module scope, outside fn main(), and share the generated types across your app. The Neovim binding also defines Terminal.

Checks cover the workspace's Zed revision and gpui-pre 0.3.4. GPUI API changes may require an adapter update; arbitrary revisions are not guaranteed.

License

The workspace is MIT-licensed. Vendored Ghostty remains MIT-licensed; see crates/gpui-ghostty/vendor/ghostty/LICENSE and crates/gpui-ghostty/vendor/ghostty/VENDOR.md.