Mountain/Environment/Utility/
LanguageDetection.rs1use std::{ffi::OsStr, path::Path};
6
7pub fn DetectLanguageIdentifierFromFilePath(Path:&Path) -> String {
10 match Path.extension().and_then(OsStr::to_str) {
11 Some("js") | Some("mjs") | Some("cjs") => "javascript",
12 Some("ts") | Some("mts") | Some("cts") => "typescript",
13 Some("jsx") => "javascriptreact",
14 Some("tsx") => "typescriptreact",
15 Some("rs") => "rust",
16 Some("md") => "markdown",
17 Some("json") => "json",
18 Some("html") => "html",
19 Some("css") => "css",
20 _ => "plaintext",
21 }
22 .to_string()
23}