From 9cddf64ac51fc5e7c5474e7aeaa2ef8f069220db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Dominique?= Date: Fri, 4 Aug 2023 14:38:23 -0400 Subject: [PATCH] feat: Cuttlefish mode (#5278) Added a highlighter for the Cuttlefish format, used in Erlang applications. --- demo/kitchen-sink/docs/cuttlefish.conf | 11 ++++++++ src/ext/modelist.js | 1 + src/mode/cuttlefish.js | 20 ++++++++++++++ src/mode/cuttlefish_highlight_rules.js | 36 ++++++++++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 demo/kitchen-sink/docs/cuttlefish.conf create mode 100644 src/mode/cuttlefish.js create mode 100644 src/mode/cuttlefish_highlight_rules.js diff --git a/demo/kitchen-sink/docs/cuttlefish.conf b/demo/kitchen-sink/docs/cuttlefish.conf new file mode 100644 index 00000000000..984966e8abd --- /dev/null +++ b/demo/kitchen-sink/docs/cuttlefish.conf @@ -0,0 +1,11 @@ +include extras.conf # overflow config file + +ring_size = 32 + +# experimental +anti_entropy = debug + +# logging +log.error.file = /var/log/error.log +log.console.file = /var/log/console.log +log.syslog = on diff --git a/src/ext/modelist.js b/src/ext/modelist.js index aac3e8fbede..efa090114e7 100644 --- a/src/ext/modelist.js +++ b/src/ext/modelist.js @@ -73,6 +73,7 @@ var supportedModes = { Csound_Score: ["sco"], CSS: ["css"], Curly: ["curly"], + Cuttlefish: ["conf"], D: ["d|di"], Dart: ["dart"], Diff: ["diff|patch"], diff --git a/src/mode/cuttlefish.js b/src/mode/cuttlefish.js new file mode 100644 index 00000000000..635bf245175 --- /dev/null +++ b/src/mode/cuttlefish.js @@ -0,0 +1,20 @@ +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CuttlefishHighlightRules = require("./cuttlefish_highlight_rules").CuttlefishHighlightRules; + +var Mode = function() { + this.HighlightRules = CuttlefishHighlightRules; + this.foldingRules = null; + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "#"; + this.blockComment = null; + this.$id = "ace/mode/cuttlefish"; +}).call(Mode.prototype); + +exports.Mode = Mode; diff --git a/src/mode/cuttlefish_highlight_rules.js b/src/mode/cuttlefish_highlight_rules.js new file mode 100644 index 00000000000..0d163ef47bd --- /dev/null +++ b/src/mode/cuttlefish_highlight_rules.js @@ -0,0 +1,36 @@ +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + +var CuttlefishHighlightRules = function () { + this.$rules = { + start: [{ + token: ['text', 'comment'], + regex: /^([ \t]*)(#.*)$/ + }, { + token: ['text', 'keyword', 'text', 'string', 'text', 'comment'], + regex: /^([ \t]*)(include)([ \t]*)([A-Za-z0-9-\_\.\*\/]+)([ \t]*)(#.*)?$/ + }, { + token: ['text', 'keyword', 'text', 'operator', 'text', 'string', 'text', 'comment'], + regex: /^([ \t]*)([A-Za-z0-9-_]+(?:\.[A-Za-z0-9-_]+)*)([ \t]*)(=)([ \t]*)([^ \t#][^#]*?)([ \t]*)(#.*)?$/ + }, { + defaultToken: 'invalid' + }] + }; + + this.normalizeRules(); +}; + +CuttlefishHighlightRules.metaData = { + fileTypes: ['conf'], + keyEquivalent: '^~C', + name: 'Cuttlefish', + scopeName: 'source.conf' +}; + + +oop.inherits(CuttlefishHighlightRules, TextHighlightRules); + +exports.CuttlefishHighlightRules = CuttlefishHighlightRules;