Skip to content

Instantly share code, notes, and snippets.

@pronvit
Created August 13, 2014 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pronvit/c20e3577fd2f9683a144 to your computer and use it in GitHub Desktop.
Save pronvit/c20e3577fd2f9683a144 to your computer and use it in GitHub Desktop.
Ace editor syntax highlighting for Dwarf Fortress config files
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var DFHighlightRules = function() {
this.$rules = {
"start": [
{
token: "paren.lparen",
regex: "\\s*\\[",
next: "inside",
},
{
token: "comment",
regex: ".*$"
},
],
"inside": [
{
token: "paren.rparen",
regex: "]",
next: "start"
},
{
token: ['constant.other', "constant.numeric"],
regex: "(:)([+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b)"
},
{
token: ['constant.other', 'constant'],
regex: /(:)([A-Z_0-9]+)(?=[:\]])/
},
{
token: ['constant.other', 'string'],
regex: /(:)([^:\]]+)/
},
{
token: ['constant.language'],
regex: /([a-zA-Z_0-9]+)/
},
]
};
};
oop.inherits(DFHighlightRules, TextHighlightRules);
exports.DFHighlightRules = DFHighlightRules;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment