ext-modelist.js 6.4 KB

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