ext-modelist.js 5.9 KB

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