ext-modelist.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. GraphQLSchema: ["gql"],
  77. Groovy: ["groovy"],
  78. HAML: ["haml"],
  79. Handlebars: ["hbs|handlebars|tpl|mustache"],
  80. Haskell: ["hs"],
  81. Haskell_Cabal: ["cabal"],
  82. haXe: ["hx"],
  83. Hjson: ["hjson"],
  84. HTML: ["html|htm|xhtml"],
  85. HTML_Elixir: ["eex|html.eex"],
  86. HTML_Ruby: ["erb|rhtml|html.erb"],
  87. INI: ["ini|conf|cfg|prefs"],
  88. Io: ["io"],
  89. Jack: ["jack"],
  90. Jade: ["jade|pug"],
  91. Java: ["java"],
  92. JavaScript: ["js|jsm|jsx"],
  93. JSON: ["json"],
  94. JSONiq: ["jq"],
  95. JSP: ["jsp"],
  96. JSX: ["jsx"],
  97. Julia: ["jl"],
  98. Kotlin: ["kt|kts"],
  99. LaTeX: ["tex|latex|ltx|bib"],
  100. LESS: ["less"],
  101. Liquid: ["liquid"],
  102. Lisp: ["lisp"],
  103. LiveScript: ["ls"],
  104. LogiQL: ["logic|lql"],
  105. LSL: ["lsl"],
  106. Lua: ["lua"],
  107. LuaPage: ["lp"],
  108. Lucene: ["lucene"],
  109. Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
  110. Markdown: ["md|markdown"],
  111. Mask: ["mask"],
  112. MATLAB: ["matlab"],
  113. Maze: ["mz"],
  114. MEL: ["mel"],
  115. MUSHCode: ["mc|mush"],
  116. MySQL: ["mysql"],
  117. Nix: ["nix"],
  118. NSIS: ["nsi|nsh"],
  119. ObjectiveC: ["m|mm"],
  120. OCaml: ["ml|mli"],
  121. Pascal: ["pas|p"],
  122. Perl: ["pl|pm"],
  123. pgSQL: ["pgsql"],
  124. PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
  125. Pig: ["pig"],
  126. Powershell: ["ps1"],
  127. Praat: ["praat|praatscript|psc|proc"],
  128. Prolog: ["plg|prolog"],
  129. Properties: ["properties"],
  130. Protobuf: ["proto"],
  131. Python: ["py"],
  132. R: ["r"],
  133. Razor: ["cshtml|asp"],
  134. RDoc: ["Rd"],
  135. RHTML: ["Rhtml"],
  136. RST: ["rst"],
  137. Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
  138. Rust: ["rs"],
  139. SASS: ["sass"],
  140. SCAD: ["scad"],
  141. Scala: ["scala"],
  142. Scheme: ["scm|sm|rkt|oak|scheme"],
  143. SCSS: ["scss"],
  144. SH: ["sh|bash|^.bashrc"],
  145. SJS: ["sjs"],
  146. Smarty: ["smarty|tpl"],
  147. snippets: ["snippets"],
  148. Soy_Template:["soy"],
  149. Space: ["space"],
  150. SQL: ["sql"],
  151. SQLServer: ["sqlserver"],
  152. Stylus: ["styl|stylus"],
  153. SVG: ["svg"],
  154. Swift: ["swift"],
  155. Tcl: ["tcl"],
  156. Tex: ["tex"],
  157. Text: ["txt"],
  158. Textile: ["textile"],
  159. Toml: ["toml"],
  160. TSX: ["tsx"],
  161. Twig: ["twig|swig"],
  162. Typescript: ["ts|typescript|str"],
  163. Vala: ["vala"],
  164. VBScript: ["vbs|vb"],
  165. Velocity: ["vm"],
  166. Verilog: ["v|vh|sv|svh"],
  167. VHDL: ["vhd|vhdl"],
  168. Wollok: ["wlk|wpgm|wtest"],
  169. XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
  170. XQuery: ["xq"],
  171. YAML: ["yaml|yml"],
  172. Django: ["html"]
  173. };
  174. var nameOverrides = {
  175. ObjectiveC: "Objective-C",
  176. CSharp: "C#",
  177. golang: "Go",
  178. C_Cpp: "C and C++",
  179. coffee: "CoffeeScript",
  180. HTML_Ruby: "HTML (Ruby)",
  181. HTML_Elixir: "HTML (Elixir)",
  182. FTL: "FreeMarker"
  183. };
  184. var modesByName = {};
  185. for (var name in supportedModes) {
  186. var data = supportedModes[name];
  187. var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
  188. var filename = name.toLowerCase();
  189. var mode = new Mode(filename, displayName, data[0]);
  190. modesByName[filename] = mode;
  191. modes.push(mode);
  192. }
  193. module.exports = {
  194. getModeForPath: getModeForPath,
  195. modes: modes,
  196. modesByName: modesByName
  197. };
  198. });
  199. (function() {
  200. ace.require(["ace/ext/modelist"], function() {});
  201. })();