Skip to content

Commit

Permalink
feat: Cuttlefish mode (#5278)
Browse files Browse the repository at this point in the history
Added a highlighter for the Cuttlefish format, used in Erlang applications.
  • Loading branch information
SignalWhisperer committed Aug 4, 2023
1 parent 1e6fcf3 commit 9cddf64
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
11 changes: 11 additions & 0 deletions demo/kitchen-sink/docs/cuttlefish.conf
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/ext/modelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var supportedModes = {
Csound_Score: ["sco"],
CSS: ["css"],
Curly: ["curly"],
Cuttlefish: ["conf"],
D: ["d|di"],
Dart: ["dart"],
Diff: ["diff|patch"],
Expand Down
20 changes: 20 additions & 0 deletions src/mode/cuttlefish.js
Original file line number Diff line number Diff line change
@@ -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;
36 changes: 36 additions & 0 deletions src/mode/cuttlefish_highlight_rules.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 9cddf64

Please sign in to comment.