Skip to main content

Crate kamon

Crate kamon 

Source
Expand description

Kamon (家紋) — file type icon provider with Nerd Font support.

A pure Rust library that maps filenames and extensions to Nerd Font icons and their associated colors. Designed to be a data/lookup library with no external dependencies beyond std.

§Usage

use kamon::{get_icon, get_icon_by_extension, Icon};

// Look up by full filename (handles special names like Dockerfile, Makefile)
let icon = get_icon("main.rs").unwrap();
assert_eq!(icon.name, "rust");
assert_eq!(icon.color, "#dea584");

// Look up by extension directly
let icon = get_icon_by_extension("py").unwrap();
assert_eq!(icon.name, "python");

// Returns a default icon for unknown file types
let icon = get_icon("mystery_file");
assert!(icon.is_some()); // always returns an icon (default fallback)

Modules§

detect
Filename detection: extracts extension and handles special filenames.
icons
Icon database: maps extensions and special filenames to Nerd Font icons.

Structs§

Icon
A file type icon with its Nerd Font glyph, human-readable name, and color.

Functions§

default_icon
Get the default fallback icon used for unknown file types.
get_icon
Look up an icon for a filename or path.
get_icon_by_extension
Look up an icon by file extension (without the leading dot).
icon_and_color
Convenience: get an (icon_glyph, color_hex) tuple for a filename.
try_get_icon
Look up an icon for a filename or path, returning None if no match is found.