2021-03-21 19:26:28 +01:00
|
|
|
package org.mian.gitnex.core;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author opyale
|
|
|
|
*/
|
2022-09-30 05:04:01 +02:00
|
|
|
public class MainGrammarLocator {
|
2022-08-15 16:26:02 +02:00
|
|
|
|
2022-09-30 05:04:01 +02:00
|
|
|
public static final String DEFAULT_FALLBACK_LANGUAGE = null; // "clike";
|
2021-03-21 19:26:28 +01:00
|
|
|
|
2022-09-30 05:04:01 +02:00
|
|
|
public static String fromExtension(String extension) {
|
2021-03-21 19:26:28 +01:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
switch (extension.toLowerCase()) {
|
2021-03-21 19:26:28 +01:00
|
|
|
case "b":
|
|
|
|
case "bf":
|
|
|
|
return "brainfuck";
|
|
|
|
|
|
|
|
case "c":
|
|
|
|
case "h":
|
|
|
|
case "hdl":
|
|
|
|
return "c";
|
|
|
|
|
|
|
|
case "clj":
|
|
|
|
case "cljs":
|
|
|
|
case "cljc":
|
|
|
|
case "edn":
|
|
|
|
return "clojure";
|
|
|
|
|
|
|
|
case "cc":
|
|
|
|
case "cpp":
|
|
|
|
case "cxx":
|
|
|
|
case "c++":
|
|
|
|
case "hh":
|
|
|
|
case "hpp":
|
|
|
|
case "hxx":
|
|
|
|
case "h++":
|
|
|
|
return "cpp";
|
|
|
|
|
|
|
|
case "cs":
|
|
|
|
case "csx":
|
|
|
|
return "csharp";
|
|
|
|
|
|
|
|
case "groovy":
|
|
|
|
case "gradle":
|
|
|
|
case "gvy":
|
|
|
|
case "gy":
|
|
|
|
case "gsh":
|
|
|
|
return "groovy";
|
|
|
|
|
|
|
|
case "js":
|
|
|
|
case "cjs":
|
|
|
|
case "mjs":
|
|
|
|
return "javascript";
|
|
|
|
|
|
|
|
case "kt":
|
|
|
|
case "kts":
|
|
|
|
case "ktm":
|
|
|
|
return "kotlin";
|
|
|
|
|
|
|
|
case "md":
|
|
|
|
return "markdown";
|
|
|
|
|
2022-09-30 05:04:01 +02:00
|
|
|
// case "xml":
|
|
|
|
// case "html":
|
|
|
|
// case "htm":
|
2021-03-21 19:26:28 +01:00
|
|
|
case "mathml":
|
|
|
|
case "svg":
|
|
|
|
return "markup";
|
|
|
|
|
|
|
|
case "py":
|
|
|
|
case "pyi":
|
|
|
|
case "pyc":
|
|
|
|
case "pyd":
|
|
|
|
case "pyo":
|
|
|
|
case "pyw":
|
|
|
|
case "pyz":
|
|
|
|
return "python";
|
|
|
|
|
|
|
|
case "scala":
|
|
|
|
case "sc":
|
|
|
|
return "scala";
|
|
|
|
|
2023-03-26 08:11:59 +02:00
|
|
|
case "el":
|
|
|
|
case "lisp":
|
|
|
|
return "lisp";
|
|
|
|
|
2021-03-21 19:26:28 +01:00
|
|
|
case "yaml":
|
|
|
|
case "yml":
|
2022-09-21 07:43:00 +02:00
|
|
|
case "properties": // This extension doesn't correspond to YAML, but it's the next best
|
|
|
|
// option
|
2021-03-21 19:26:28 +01:00
|
|
|
return "yaml";
|
|
|
|
}
|
|
|
|
|
|
|
|
return extension;
|
|
|
|
}
|
|
|
|
}
|