ext-modelist.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
  2. "use strict";
  3. var modes = [];
  4. function getModeForPath(path) {
  5. var mode = modesByName.text;
  6. var fileName = path.split(/[\/\\]/).pop();
  7. for (var i = 0; i < modes.length; i++) {
  8. if (modes[i].supportsFile(fileName)) {
  9. mode = modes[i];
  10. break;
  11. }
  12. }
  13. return mode;
  14. }
  15. var Mode = function(name, caption, extensions) {
  16. this.name = name;
  17. this.caption = caption;
  18. this.mode = "ace/mode/" + name;
  19. this.extensions = extensions;
  20. if (/\^/.test(extensions)) {
  21. var re = extensions.replace(/\|(\^)?/g, function(a, b){
  22. return "$|" + (b ? "^" : "^.*\\.");
  23. }) + "$";
  24. } else {
  25. var re = "^.*\\.(" + extensions + ")$";
  26. }
  27. this.extRe = new RegExp(re, "gi");
  28. };
  29. Mode.prototype.supportsFile = function(filename) {
  30. return filename.match(this.extRe);
  31. };
  32. var supportedModes = {
  33. ABAP: ["abap"],
  34. ABC: ["abc"],
  35. ActionScript:["as"],
  36. ADA: ["ada|adb"],
  37. Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
  38. AsciiDoc: ["asciidoc|adoc"],
  39. Assembly_x86:["asm"],
  40. AutoHotKey: ["ahk"],
  41. BatchFile: ["bat|cmd"],
  42. C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
  43. C9Search: ["c9search_results"],
  44. Cirru: ["cirru|cr"],
  45. Clojure: ["clj|cljs"],
  46. Cobol: ["CBL|COB"],
  47. coffee: ["coffee|cf|cson|^Cakefile"],
  48. ColdFusion: ["cfm"],
  49. CSharp: ["cs"],
  50. CSS: ["css"],
  51. Curly: ["curly"],
  52. D: ["d|di"],
  53. Dart: ["dart"],
  54. Diff: ["diff|patch"],
  55. Dockerfile: ["^Dockerfile"],
  56. Dot: ["dot"],
  57. Dummy: ["dummy"],
  58. DummySyntax: ["dummy"],
  59. Eiffel: ["e"],
  60. EJS: ["ejs"],
  61. Elixir: ["ex|exs"],
  62. Elm: ["elm"],
  63. Erlang: ["erl|hrl"],
  64. Forth: ["frt|fs|ldr"],
  65. FTL: ["ftl"],
  66. Gcode: ["gcode"],
  67. Gherkin: ["feature"],
  68. Gitignore: ["^.gitignore"],
  69. Glsl: ["glsl|frag|vert"],
  70. golang: ["go"],
  71. Groovy: ["groovy"],
  72. HAML: ["haml"],
  73. Handlebars: ["hbs|handlebars|tpl|mustache"],
  74. Haskell: ["hs"],
  75. haXe: ["hx"],
  76. HTML: ["html|htm|xhtml"],
  77. HTML_Ruby: ["erb|rhtml|html.erb"],
  78. INI: ["ini|conf|cfg|prefs"],
  79. Io: ["io"],
  80. Jack: ["jack"],
  81. Jade: ["jade"],
  82. Java: ["java"],
  83. JavaScript: ["js|jsm"],
  84. JSON: ["json"],
  85. JSONiq: ["jq"],
  86. JSP: ["jsp"],
  87. JSX: ["jsx"],
  88. Julia: ["jl"],
  89. LaTeX: ["tex|latex|ltx|bib"],
  90. Lean: ["lean|hlean"],
  91. LESS: ["less"],
  92. Liquid: ["liquid"],
  93. Lisp: ["lisp"],
  94. LiveScript: ["ls"],
  95. LogiQL: ["logic|lql"],
  96. LSL: ["lsl"],
  97. Lua: ["lua"],
  98. LuaPage: ["lp"],
  99. Lucene: ["lucene"],
  100. Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
  101. Markdown: ["md|markdown"],
  102. Mask: ["mask"],
  103. MATLAB: ["matlab"],
  104. Maze: ["mz"],
  105. MEL: ["mel"],
  106. MUSHCode: ["mc|mush"],
  107. MySQL: ["mysql"],
  108. Nix: ["nix"],
  109. ObjectiveC: ["m|mm"],
  110. OCaml: ["ml|mli"],
  111. Pascal: ["pas|p"],
  112. Perl: ["pl|pm"],
  113. pgSQL: ["pgsql"],
  114. PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp"],
  115. Powershell: ["ps1"],
  116. Praat: ["praat|praatscript|psc|proc"],
  117. Prolog: ["plg|prolog"],
  118. Properties: ["properties"],
  119. Protobuf: ["proto"],
  120. Python: ["py"],
  121. R: ["r"],
  122. RDoc: ["Rd"],
  123. RHTML: ["Rhtml"],
  124. Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
  125. Rust: ["rs"],
  126. SASS: ["sass"],
  127. SCAD: ["scad"],
  128. Scala: ["scala"],
  129. Scheme: ["scm|rkt"],
  130. SCSS: ["scss"],
  131. SH: ["sh|bash|^.bashrc"],
  132. SJS: ["sjs"],
  133. Smarty: ["smarty|tpl"],
  134. snippets: ["snippets"],
  135. Soy_Template:["soy"],
  136. Space: ["space"],
  137. SQL: ["sql"],
  138. SQLServer: ["sqlserver"],
  139. Stylus: ["styl|stylus"],
  140. SVG: ["svg"],
  141. Tcl: ["tcl"],
  142. Tex: ["tex"],
  143. Text: ["txt"],
  144. Textile: ["textile"],
  145. Toml: ["toml"],
  146. Twig: ["twig"],
  147. Typescript: ["ts|typescript|str"],
  148. Vala: ["vala"],
  149. VBScript: ["vbs|vb"],
  150. Velocity: ["vm"],
  151. Verilog: ["v|vh|sv|svh"],
  152. VHDL: ["vhd|vhdl"],
  153. XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
  154. XQuery: ["xq"],
  155. YAML: ["yaml|yml"],
  156. Django: ["html"]
  157. };
  158. var nameOverrides = {
  159. ObjectiveC: "Objective-C",
  160. CSharp: "C#",
  161. golang: "Go",
  162. C_Cpp: "C and C++",
  163. coffee: "CoffeeScript",
  164. HTML_Ruby: "HTML (Ruby)",
  165. FTL: "FreeMarker"
  166. };
  167. var modesByName = {};
  168. for (var name in supportedModes) {
  169. var data = supportedModes[name];
  170. var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
  171. var filename = name.toLowerCase();
  172. var mode = new Mode(filename, displayName, data[0]);
  173. modesByName[filename] = mode;
  174. modes.push(mode);
  175. }
  176. module.exports = {
  177. getModeForPath: getModeForPath,
  178. modes: modes,
  179. modesByName: modesByName
  180. };
  181. });
  182. (function() {
  183. window.require(["ace/ext/modelist"], function() {});
  184. })();