From bf72097811c2285a4999b527c79b24ef5d3ea070 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 4 Jul 2014 11:25:53 -0700 Subject: [PATCH] add a gitignore mode --- demo/kitchen-sink/docs/gitignore.gitignore | 8 +++++++ lib/ace/ext/modelist.js | 1 + lib/ace/mode/gitignore.js | 19 +++++++++++++++ lib/ace/mode/gitignore_highlight_rules.js | 28 ++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 demo/kitchen-sink/docs/gitignore.gitignore create mode 100644 lib/ace/mode/gitignore.js create mode 100644 lib/ace/mode/gitignore_highlight_rules.js diff --git a/demo/kitchen-sink/docs/gitignore.gitignore b/demo/kitchen-sink/docs/gitignore.gitignore new file mode 100644 index 00000000..80f4f386 --- /dev/null +++ b/demo/kitchen-sink/docs/gitignore.gitignore @@ -0,0 +1,8 @@ +# A sample .gitiignore file. + +.buildlog +.DS_Store +.svn + +# Also ignore user settings... +/.settings diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index 57470ed0..15a31610 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -70,6 +70,7 @@ var supportedModes = { Forth: ["frt|fs|ldr"], FTL: ["ftl"], Gherkin: ["feature"], + Gitignore: ["^.gitignore"], Glsl: ["glsl|frag|vert"], golang: ["go"], Groovy: ["groovy"], diff --git a/lib/ace/mode/gitignore.js b/lib/ace/mode/gitignore.js new file mode 100644 index 00000000..fd9b04f4 --- /dev/null +++ b/lib/ace/mode/gitignore.js @@ -0,0 +1,19 @@ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var GitignoreHighlightRules = require("./gitignore_highlight_rules").GitignoreHighlightRules; + +var Mode = function() { + this.HighlightRules = GitignoreHighlightRules; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.$id = "ace/mode/gitignore"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/gitignore_highlight_rules.js b/lib/ace/mode/gitignore_highlight_rules.js new file mode 100644 index 00000000..8889511d --- /dev/null +++ b/lib/ace/mode/gitignore_highlight_rules.js @@ -0,0 +1,28 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var GitignoreHighlightRules = function() { + this.$rules = { + "start" : [ + { + token : "comment", + regex : /[#].*$/ + } + ] + }; + + this.normalizeRules(); +}; + +GitignoreHighlightRules.metaData = { + fileTypes: ['gitignore'], + name: 'Gitignore' +}; + +oop.inherits(GitignoreHighlightRules, TextHighlightRules); + +exports.GitignoreHighlightRules = GitignoreHighlightRules; +});