MCPcopy Index your code
hub / github.com/Digital-Shane/treeview

github.com/Digital-Shane/treeview @v2.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.1 ↗ · + Follow
639 symbols 2,106 edges 57 files 374 documented · 59% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

TreeView

TreeView is a feature-rich Go library for displaying and navigating tree structures in the terminal. TreeView has full Bubble Tea and Lipgloss support, allowing you to build glamorous, interactive terminal applications.

If you're upgrading from v1, the v2 update guide walks through the important changes and what to watch for.

Why TreeView?

What sets TreeView apart is its flexibility. You can build trees from any data source: flat lists with parent relationships, pre-nested hierarchical data, or create trees from your filesystem. The search and filtering system uses customizable predicates, giving you complete control over how users find what they're looking for. Search results automatically expand ancestor nodes so matches are visible, and the real-time filtering keeps the tree structure intact while hiding irrelevant items. When dealing with large trees, the bubbletea viewport support ensures smooth scrolling and focus. Navigation feels natural with keyboard bindings that you can customize to match your app's needs.

The styling system is particularly powerful. TreeView automatically detects file types and applies appropriate icons, but you can customize everything through the provider system to style any hierarchical with glamor. Whether you want subtle themes or vibrant, emoji-heavy displays, the Lipgloss integration makes it straightforward.

TreeView is ready for production. It provides proper error handling with sentinel errors, operations respect context cancellation and timeouts, and the library is thread-safe where it matters.


Examples

The examples directory contains twelve progressively complex demonstrations, from basic tree rendering to a fully-featured file browser. Each example includes comments and animated demos, so you can see exactly how to implement specific features in your own applications.

Basic Examples

Basic examples only demonstrate building and rendering a tree in the console.

Simple Tree
This example demonstrates the fundamental tree creation and rendering capabilities of the TreeView library.

Demo

Iterators
This example demonstrates how to range over a tree's nodes using the provided iterators.

Demo

Custom Styling
A showcase of the styling capabilities provided via lipgloss support

Demo

Comparison Display
This example demonstrates visualizing comparison operations with before and after displays.

Demo

Workflow Visualization
Example showing how to create domain-specific tree nodes for process and workflow tracking.

Demo

Build Trees From Parent Relationships
Shows how to use BuildTree to create trees from flat data structures where relationships are defined by parent ID references.

Demo

Build Trees From Hierarchical Data
Demonstrates using BuildTree for constructing trees from naturally hierarchical data structures.

Demo

Filesystem Builder
Demonstrates creating filesystem tree structures with NewTreeFromFileSystem constructor with support for special path characters like ., .., and ~. Shows path resolution, configurable depth limits, hidden file handling, and automatic file type detection for styling.

Demo


Intermediate Examples

Intermediate examples demonstrate treeview's full TUI support via BubbleTea.

Keyboard Controls
Advanced interactive example demonstrating comprehensive keyboard-based navigation within tree structures. Shows how to implement arrow key navigation, selection management, and basic searching.

Demo

Search & Filtering
This example demonstrates extending the search functionality to handle domain data.

Demo

Viewport Rendering
Demonstrates viewport-aware rendering for handling large tree structures. Solves the common problem of cursor navigation going off-screen in large directory trees by implementing automatic scrolling and responsive viewport management.

Demo

File Browser
Complete, terminal file browser application built with TreeView and Bubble Tea.

Demo

Contributing

Contributions are welcome! If you have any suggestions or encounter a bug, please open an issue or submit a pull request.

When contributing:

  1. Fork the repository and create a new feature branch
  2. Make your changes in a well-structured commit history
  3. Include tests (when applicable)
  4. Submit a pull request with a clear description of your changes

License

This project is licensed under the GNU Version 3 - see the LICENSE file for details.

Acknowledgments

TreeView is built on top of the excellent Charm ecosystem: - Bubble Tea for TUI framework - Lipgloss for styling and layout - VHS for epic scriptable demos - Charm community for inspiration and gif hosting!

Star History

Star History Chart


Extension points exported contracts — how you extend this code

NestedDataProvider (Interface)
NestedDataProvider is the counterpart for BuildTreeFromNestedData. It exposes just the fundamental accessors needed to t [4 …
constructors.go
Walker (Interface)
Walker provides a source-specific traversal adapter for NewTreeFromWalker. Implementations provide the root item and en [3 …
walker.go
NodeProvider (Interface)
NodeProvider lets you plug custom rendering logic into treeview. The generic parameter T represents your domain object t [1 …
providers.go
TuiTreeModelOption (FuncType)
TuiTreeModelOption represents a functional Option that configures a TuiTreeModel instance directly.
tui.go
SearchFn (FuncType)
SearchFn returns true if the node matches the search term.
option.go
Option (FuncType)
Option allows parameterizing a function
extensions/s3/internal/s3/opts.go
FlatDataProvider (Interface)
FlatDataProvider is the counterpart for BuildTreeFromFlatData. It exposes just the fundamental accessors needed to build [4 …
constructors.go
ProviderOption (FuncType)
ProviderOption is a function that configures a DefaultNodeProvider.
providers.go

Core symbols most depended-on inside this repo

NewNode
called by 141
node.go
NewFileNode
called by 115
examples/intermediate/03-viewport/main.go
AddFileChild
called by 114
examples/intermediate/03-viewport/main.go
AddChild
called by 100
node.go
Children
called by 86
walker.go
Name
called by 54
constructors.go
ID
called by 51
constructors.go
NewTree
called by 49
constructors.go

Shape

Function 372
Method 185
Struct 64
FuncType 10
Interface 5
TypeAlias 3

Languages

Go100%

Modules by API surface

examples/basic/07-builders-nested/main.go38 symbols
tui.go31 symbols
tree.go30 symbols
examples/intermediate/04-file-browser/main.go27 symbols
providers_test.go26 symbols
option.go25 symbols
examples/basic/06-builders-flat/main.go25 symbols
node.go23 symbols
constructors_test.go23 symbols
constructors.go23 symbols
tree_test.go22 symbols
providers.go22 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add treeview \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact