fuzzyfinder

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package fuzzyfinder implements a fuzzy search overlay for grut. It provides a unified interface for searching files, commands, and other sources with real-time fuzzy matching and highlighted results.

Index

Constants

View Source
const DefaultDirectorySourceMaxDepth = 5

--------------------------------------------------------------------------- DirectorySource --------------------------------------------------------------------------- DefaultDirectorySourceMaxDepth is the default recursion depth used when presenting candidate directories in the change-directory fuzzy finder.

Variables

This section is empty.

Functions

func InvalidateFileCache

func InvalidateFileCache()

InvalidateFileCache marks the global file-list cache as invalid so that the next fuzzy-finder open re-walks the filesystem.

Types

type CommandSource

type CommandSource struct {
	// contains filtered or unexported fields
}

--------------------------------------------------------------------------- CommandSource --------------------------------------------------------------------------- CommandSource provides keymap bindings as searchable items for the command palette. Actions are deduplicated so each action appears once, using the first binding's key and description.

func NewCommandSource

func NewCommandSource(bindings []keymap.Binding) *CommandSource

NewCommandSource creates a source from keymap bindings.

func (*CommandSource) Items

func (cs *CommandSource) Items() []Item

Items implements Source. It returns deduplicated command bindings as searchable items, with the action as text and the key combination shown in the description.

func (*CommandSource) Name

func (cs *CommandSource) Name() string

Name implements Source.

type DirectorySource

type DirectorySource struct {
	// contains filtered or unexported fields
}

DirectorySource walks a directory tree and provides directory paths as searchable items for the change-directory fuzzy finder. Hidden directories (names starting with ".") and directories matched by .gitignore rules are excluded. When no .gitignore exists, a hardcoded skip list filters common non-navigable directories (node_modules, vendor, __pycache__, etc.).

func NewDirectorySource

func NewDirectorySource(root string, maxDepth int) *DirectorySource

NewDirectorySource creates a source that walks the given root directory and returns subdirectories up to maxDepth levels deep.

func (*DirectorySource) Items

func (ds *DirectorySource) Items() []Item

Items implements Source. It walks the directory tree rooted at ds.root and returns subdirectories as searchable items, skipping hidden and ignored directories.

func (*DirectorySource) Name

func (ds *DirectorySource) Name() string

Name implements Source.

type FileSource

type FileSource struct {
	// contains filtered or unexported fields
}

--------------------------------------------------------------------------- FileSource --------------------------------------------------------------------------- FileSource walks a directory tree and provides file paths as searchable items. Hidden files and directories (names starting with ".") are excluded from the results. Results are cached to avoid repeated walks.

func NewFileSource

func NewFileSource(root string) *FileSource

NewFileSource creates a source that walks the given root directory.

func (*FileSource) Items

func (fs *FileSource) Items() []Item

Items implements Source. It checks the global cache first and falls back to walking the directory tree rooted at fs.root, filtering entries via .gitignore rules when available.

func (*FileSource) Name

func (fs *FileSource) Name() string

Name implements Source.

type FuzzyFinder

type FuzzyFinder struct {
	panels.BasePanel
	// contains filtered or unexported fields
}

FuzzyFinder is an overlay panel for fuzzy searching files and commands. It implements panels.Panel and is rendered as a floating overlay on top of the main layout by the root model.

func New

func New(th *theme.Theme, sources ...Source) *FuzzyFinder

New creates a new FuzzyFinder with the given sources. Items are loaded eagerly from all sources at construction time.

func (*FuzzyFinder) Init

func (ff *FuzzyFinder) Init(_ context.Context) tea.Cmd

--------------------------------------------------------------------------- panels.Panel interface --------------------------------------------------------------------------- Init implements panels.Panel.

func (*FuzzyFinder) KeyBindings

func (ff *FuzzyFinder) KeyBindings() []panels.KeyBinding

KeyBindings implements panels.Panel.

func (*FuzzyFinder) Update

func (ff *FuzzyFinder) Update(msg tea.Msg) (panels.Panel, tea.Cmd)

Update implements panels.Panel.

func (*FuzzyFinder) View

func (ff *FuzzyFinder) View(width, height int) string

View implements panels.Panel. It renders the fuzzy finder content including the search input, results list with match highlighting, and a status bar showing match counts.

type Item

type Item struct {
	Value       any    // Arbitrary data for the result handler
	Text        string // Searchable text (what fuzzy matches against)
	Description string // Secondary text shown in results
	Category    string // Source category for display grouping
}

Item represents a single searchable entry in the fuzzy finder.

type Source

type Source interface {
	// Name returns the source category name (e.g. "files", "commands").
	Name() string
	// Items returns all searchable items from this source.
	Items() []Item
}

Source provides searchable items for the fuzzy finder. Implementations gather items from a specific domain (files, commands, bookmarks, etc.) and return them as a flat list for fuzzy matching.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL