$ show vhakulinen/gnvim
GNvim is a GTK4-based Neovim GUI written in Rust. It communicates with Neovim via the MessagePack-RPC protocol, providing a native desktop experience with features like floating windows, popup menus, tabline, cmdline, and smooth animations for cursor and scrolling. The architecture is a single Rust binary split into a workspace: the main `ui` crate contains the GTK4 frontend with custom widgets (e.g., Grid, GridBuffer, Cursor, Fixedz, Popupmenu, Shell), and the `nvim-rs` library crate provides a reusable, async RPC client for Neovim with auto-generated API bindings. The system's entry point is `ui/src/main.rs`, which registers resources and launches the GTK application. Data flows bidirectionally: Neovim sends UI events (redraw, options, notifications) as RPC messages, which are deserialized into Rust types and applied to the GTK widget tree; user input (keyboard, mouse) is captured by GTK event controllers and sent back to Neovim as RPC calls. The codebase is well-structured, modular, and follows modern Rust async patterns, with extensive use of GTK4's property system and custom layout managers for complex UI composition.
The LLM identified 3 files worth highlighting for reuse:
Implements the MessagePack-RPC protocol for Neovim, including Request, Response, and Notification structs with custom serialization/deserialization via serde. This is a self-contained, reusable module that can be extracted to build any MessagePack-RPC client, not just for Neovim. It demonstrates clean, idiomatic Rust with manual serde implementation for performance and correctness.
Provides the core async RPC client for Neovim, managing message IDs, pending callbacks, and writing requests. It is designed to be generic over any writer and can be reused as a base for any Neovim UI extension. The `Client` struct uses `RefCell` and `Mutex` for interior mutability, supporting non-Send environments like GTK's main loop. The code is clean and well-documented, with integration tests demonstrating usage.
A custom GTK4 layout manager (`Fixedz`) that positions children using explicit x, y coordinates and z-index, similar to `GtkFixed` but with depth ordering. The implementation includes a custom layout child with position and z-index properties, and a layout manager that measures and allocates children accordingly. This is a reusable pattern for any GTK4 application requiring absolute positioning with stacking order, and it demonstrates deep understanding of GTK4's layout system.