You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
6.3 KiB

10 months ago
  1. ace.define("ace/ext/modelist",["require","exports","module"], function(acequire, 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. Csound_Document: ["csd"],
  53. Csound_Orchestra: ["orc"],
  54. Csound_Score: ["sco"],
  55. CSS: ["css"],
  56. Curly: ["curly"],
  57. D: ["d|di"],
  58. Dart: ["dart"],
  59. Diff: ["diff|patch"],
  60. Dockerfile: ["^Dockerfile"],
  61. Dot: ["dot"],
  62. Drools: ["drl"],
  63. Dummy: ["dummy"],
  64. DummySyntax: ["dummy"],
  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. MUSHCode: ["mc|mush"],
  120. MySQL: ["mysql"],
  121. Nix: ["nix"],
  122. NSIS: ["nsi|nsh"],
  123. ObjectiveC: ["m|mm"],
  124. OCaml: ["ml|mli"],
  125. Pascal: ["pas|p"],
  126. Perl: ["pl|pm"],
  127. pgSQL: ["pgsql"],
  128. PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
  129. Pig: ["pig"],
  130. Powershell: ["ps1"],
  131. Praat: ["praat|praatscript|psc|proc"],
  132. Prolog: ["plg|prolog"],
  133. Properties: ["properties"],
  134. Protobuf: ["proto"],
  135. Python: ["py"],
  136. R: ["r"],
  137. Razor: ["cshtml|asp"],
  138. RDoc: ["Rd"],
  139. Red: ["red|reds"],
  140. RHTML: ["Rhtml"],
  141. RST: ["rst"],
  142. Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
  143. Rust: ["rs"],
  144. SASS: ["sass"],
  145. SCAD: ["scad"],
  146. Scala: ["scala"],
  147. Scheme: ["scm|sm|rkt|oak|scheme"],
  148. SCSS: ["scss"],
  149. SH: ["sh|bash|^.bashrc"],
  150. SJS: ["sjs"],
  151. Smarty: ["smarty|tpl"],
  152. snippets: ["snippets"],
  153. Soy_Template:["soy"],
  154. Space: ["space"],
  155. SQL: ["sql"],
  156. SQLServer: ["sqlserver"],
  157. Stylus: ["styl|stylus"],
  158. SVG: ["svg"],
  159. Swift: ["swift"],
  160. Tcl: ["tcl"],
  161. Tex: ["tex"],
  162. Text: ["txt"],
  163. Textile: ["textile"],
  164. Toml: ["toml"],
  165. TSX: ["tsx"],
  166. Twig: ["twig|swig"],
  167. Typescript: ["ts|typescript|str"],
  168. Vala: ["vala"],
  169. VBScript: ["vbs|vb"],
  170. Velocity: ["vm"],
  171. Verilog: ["v|vh|sv|svh"],
  172. VHDL: ["vhd|vhdl"],
  173. Wollok: ["wlk|wpgm|wtest"],
  174. XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
  175. XQuery: ["xq"],
  176. YAML: ["yaml|yml"],
  177. Django: ["html"]
  178. };
  179. var nameOverrides = {
  180. ObjectiveC: "Objective-C",
  181. CSharp: "C#",
  182. golang: "Go",
  183. C_Cpp: "C and C++",
  184. Csound_Document: "Csound Document",
  185. Csound_Orchestra: "Csound",
  186. Csound_Score: "Csound Score",
  187. coffee: "CoffeeScript",
  188. HTML_Ruby: "HTML (Ruby)",
  189. HTML_Elixir: "HTML (Elixir)",
  190. FTL: "FreeMarker"
  191. };
  192. var modesByName = {};
  193. for (var name in supportedModes) {
  194. var data = supportedModes[name];
  195. var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
  196. var filename = name.toLowerCase();
  197. var mode = new Mode(filename, displayName, data[0]);
  198. modesByName[filename] = mode;
  199. modes.push(mode);
  200. }
  201. module.exports = {
  202. getModeForPath: getModeForPath,
  203. modes: modes,
  204. modesByName: modesByName
  205. };
  206. });
  207. (function() {
  208. ace.acequire(["ace/ext/modelist"], function() {});
  209. })();