MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / detect_language

Function detect_language

crates/opencode-lsp/src/lib.rs:895–923  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

893}
894
895pub fn detect_language(path: &Path) -> &'static str {
896 match path.extension().and_then(|e| e.to_str()) {
897 Some("rs") => "rust",
898 Some("ts") => "typescript",
899 Some("tsx") => "typescriptreact",
900 Some("js") => "javascript",
901 Some("jsx") => "javascriptreact",
902 Some("py") => "python",
903 Some("go") => "go",
904 Some("java") => "java",
905 Some("c") => "c",
906 Some("cpp") | Some("cc") | Some("cxx") => "cpp",
907 Some("h") | Some("hpp") => "cpp",
908 Some("rb") => "ruby",
909 Some("php") => "php",
910 Some("swift") => "swift",
911 Some("kt") => "kotlin",
912 Some("scala") => "scala",
913 Some("lua") => "lua",
914 Some("json") => "json",
915 Some("yaml") | Some("yml") => "yaml",
916 Some("toml") => "toml",
917 Some("md") => "markdown",
918 Some("html") => "html",
919 Some("css") => "css",
920 Some("scss") => "scss",
921 _ => "plaintext",
922 }
923}
924
925#[cfg(test)]
926mod tests {

Callers 7

has_clientsMethod · 0.85
touch_fileMethod · 0.85
execute_with_lspFunction · 0.85
get_lsp_diagnostics_implFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected