use crate::core::FileEntry;
use phf::phf_map;
static EXT_ICON_MAP: phf::Map<&'static str, &'static str> = phf_map! {
"rs" => "",
"py" => "",
"js" => "",
"md" => "",
"html" => "",
"css" => "",
"json" => "",
"xml" => "",
"sh" => "",
"go" => "",
"java" => "",
"c" => "",
"cpp" => "",
"h" => "",
"hpp" => "",
"php" => "",
"rb" => "",
"swift" => "",
"kt" => "",
"lua" => "",
"ts" => "",
"tsx" => "",
"jsx" => "",
"vue" => "",
"sql" => "",
"lock" => "",
"exe" => "",
"zip" => "",
"tar" => "",
"gz" => "",
"mp3" => "",
"mp4" => "",
"png" => "",
"jpg" => "",
"jpeg" => "",
"gif" => "",
"svg" => "",
"pdf" => "",
"doc" => "",
"docx" => "",
"xls" => "",
"xlsx" => "",
"ppt" => "",
"pptx" => "",
"txt" => "",
"log" => "",
"cfg" => "",
"config" => "",
"ini" => "",
"bat" => "",
"ps1" => "",
"cmd" => "",
"dll" => "",
"yml" => "",
"yaml" => "",
"toml" => "",
"deb" => "",
"rpm" => "",
"dmg" => "",
"appimage" => "",
"snap" => "",
"flatpak" => "",
"msi" => "",
"iso" => "",
"img" => "",
"vhd" => "",
"cab" => "",
"psd" => "",
"patch" => "",
"diff" => "",
"ebuild" => "",
"spec" => "",
};
pub static SPECIAL_FILE_ICON_MAP: phf::Map<&'static str, &'static str> = phf_map! {
"README.md" => "",
"LICENSE" => "",
"LICENSE-MIT" => "",
"LICENSE-APACHE" => "",
"COPYING" => "",
"LICENSE.txt" => "",
"Makefile" => "",
".gitignore" => "",
".gitconfig" => "",
"Cargo.toml" => "",
"Dockerfile" => "",
"package.json" => "",
"tsconfig.json" => "",
"webpack.config.js" => "",
"Pipfile" => "",
"requirements.txt" => "",
"setup.py" => "",
"config.yaml" => "",
"config.yml" => "",
".env" => "",
".env.local" => "",
".env.production" => "",
".env.development" => "",
"README" => "",
"TODO" => "",
"Dockerfile.dev" => "",
"Dockerfile.prod" => "",
"Cargo.lock" => "",
"CMakeLists.txt" => "",
"PKGBUILD" => "",
".bashrc" => "",
".vimrc" => "",
};
pub static SPECIAL_DIR_ICON_MAP: phf::Map<&'static str, &'static str> = phf_map! {
"bin" => "",
"lib" => "",
"node_modules" => "",
".git" => "",
".github" => "",
".config" => "",
"nvim" => "",
};
pub fn nerd_font_icon(entry: &FileEntry) -> &'static str {
let lowercase_name = entry.lowercase_name();
if entry.is_dir() {
if let Some(dir_icon) = SPECIAL_DIR_ICON_MAP.get(lowercase_name) {
return dir_icon;
}
return "";
}
if entry.is_symlink() {
if entry.is_dir() {
return "";
} else {
return "";
}
}
if let Some(icon) = SPECIAL_FILE_ICON_MAP.get(entry.name_str().as_ref()) {
return icon;
}
if let Some(dot_idx) = lowercase_name.rfind('.')
&& dot_idx > 0
&& dot_idx < lowercase_name.len() - 1
{
let ext = &lowercase_name[dot_idx + 1..];
if let Some(icon) = EXT_ICON_MAP.get(ext) {
return icon;
}
}
""
}