use std::path::Path;
pub fn detect(path: &Path) -> Option<(&'static str, (u8, u8, u8))> {
if let Some(ext) = path.extension().and_then(std::ffi::OsStr::to_str) {
match ext {
"ada" | "adb" | "ads" => Some(("Ada", (2, 248, 140))),
"S" | "asm" | "s" => Some(("Assembly", (110, 76, 19))),
"c" | "h" => Some(("C", (85, 85, 85))),
"cs" => Some(("C#", (115, 85, 221))),
"cc" | "cpp" | "cppm" | "cxx" | "hh" | "hpp" | "hxx" | "ixx" => Some(("C++", (243, 75, 125))),
"clj" | "cljc" | "cljs" | "edn" => Some(("Clojure", (219, 88, 85))),
"cmake" => Some(("CMake", (218, 52, 52))),
"cbl" | "cob" | "cpy" => Some(("COBOL", (136, 136, 136))),
"cr" => Some(("Crystal", (0, 1, 0))),
"css" => Some(("CSS", (102, 51, 153))),
"dart" => Some(("Dart", (0, 180, 171))),
"dhall" => Some(("Dhall", (223, 175, 255))),
"ex" | "exs" => Some(("Elixir", (110, 74, 126))),
"erl" | "hrl" => Some(("Erlang", (184, 57, 152))),
"fs" | "fsi" | "fsx" => Some(("F#", (184, 69, 252))),
"f" | "f03" | "f08" | "f77" | "f90" | "f95" | "for" => Some(("Fortran", (77, 65, 177))),
"gd" => Some(("GDScript", (53, 85, 112))),
"gleam" => Some(("Gleam", (255, 175, 243))),
"go" => Some(("Go", (0, 173, 216))),
"gql" | "graphql" => Some(("GraphQL", (225, 0, 152))),
"groovy" | "grt" | "gtpl" | "gvy" => Some(("Groovy", (66, 152, 184))),
"hs" | "lhs" => Some(("Haskell", (94, 80, 134))),
"hx" => Some(("Haxe", (223, 121, 0))),
"tf" | "tfvars" => Some(("HCL", (132, 79, 186))),
"hc" => Some(("HolyC", (255, 239, 175))),
"htm" | "html" => Some(("HTML", (227, 76, 38))),
"java" => Some(("Java", (176, 114, 25))),
"cjs" | "js" | "jsx" | "mjs" => Some(("JavaScript", (241, 224, 90))),
"jl" => Some(("Julia", (162, 112, 186))),
"just" => Some(("Just", (56, 77, 84))),
"kt" | "ktm" | "kts" => Some(("Kotlin", (169, 123, 255))),
"less" => Some(("Less", (29, 54, 93))),
"ll" => Some(("LLVM", (24, 86, 25))),
"lua" => Some(("Lua", (0, 0, 128))),
"nim" | "nims" => Some(("Nim", (255, 194, 0))),
"nix" => Some(("Nix", (126, 126, 255))),
"m" | "mm" => Some(("Objective-C", (67, 142, 255))),
"ml" | "mli" => Some(("OCaml", (239, 122, 8))),
"dpr" | "lpr" | "pas" | "pp" => Some(("Pascal", (227, 241, 113))),
"pl" | "pm" => Some(("Perl", (2, 152, 195))),
"php" => Some(("PHP", (79, 93, 149))),
"ps1" | "psd1" | "psm1" => Some(("PowerShell", (1, 36, 86))),
"purs" => Some(("PureScript", (29, 34, 45))),
"py" | "pyi" | "pyw" => Some(("Python", (53, 114, 165))),
"R" | "r" | "rd" => Some(("R", (25, 140, 231))),
"rkt" | "rktd" | "rktl" => Some(("Racket", (60, 92, 170))),
"re" | "rei" => Some(("Reason", (255, 88, 71))),
"res" | "resi" => Some(("ReScript", (237, 80, 81))),
"rb" => Some(("Ruby", (112, 21, 22))),
"rs" => Some(("Rust", (222, 165, 132))),
"sass" => Some(("Sass", (165, 59, 112))),
"sc" | "scala" => Some(("Scala", (194, 45, 64))),
"scss" => Some(("SCSS", (198, 83, 140))),
"bash" | "fish" | "ksh" | "sh" | "zsh" => Some(("Shell", (137, 224, 81))),
"sol" => Some(("Solidity", (170, 103, 70))),
"sql" => Some(("SQL", (227, 140, 0))),
"svelte" => Some(("Svelte", (255, 62, 0))),
"swift" => Some(("Swift", (240, 81, 56))),
"sv" | "svh" | "vh" => Some(("SystemVerilog", (218, 225, 194))),
"cts" | "mts" | "ts" | "tsx" => Some(("TypeScript", (49, 120, 198))),
"v" | "veo" => Some(("Verilog", (178, 183, 248))),
"vhd" | "vhdl" => Some(("VHDL", (173, 178, 203))),
"vim" => Some(("Vim Script", (25, 159, 75))),
"vue" => Some(("Vue", (65, 184, 131))),
"zep" => Some(("Zephir", (17, 143, 158))),
"zig" => Some(("Zig", (236, 145, 92))),
_ => None,
}
} else {
match path.file_name().and_then(|n| n.to_str()) {
Some("CMakeLists.txt") => Some(("CMake", (218, 52, 52))),
Some("Containerfile") => Some(("Dockerfile", (56, 77, 84))),
Some("Dockerfile") => Some(("Dockerfile", (56, 77, 84))),
Some("GNUmakefile") => Some(("Makefile", (66, 120, 25))),
Some("Makefile") => Some(("Makefile", (66, 120, 25))),
Some("dockerfile") => Some(("Dockerfile", (56, 77, 84))),
Some("makefile") => Some(("Makefile", (66, 120, 25))),
_ => None,
}
}
}