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
13 Some("ts") | Some("mts") | Some("cts") => "typescript",
14
15 Some("jsx") => "javascriptreact",
16
17 Some("tsx") => "typescriptreact",
18
19 Some("rs") => "rust",
20
21 Some("md") => "markdown",
22
23 Some("json") => "json",
24
25 Some("html") => "html",
26
27 Some("css") => "css",
28
29 _ => "plaintext",
30 }
31 .to_string()
32}