Nix mode
This commit is contained in:
parent
a44b053eab
commit
3812b20546
6 changed files with 175 additions and 96 deletions
|
|
@ -29,7 +29,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Zef Hemel
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,105 +1,119 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var NixHighlightRules = function() {
|
||||
var NixHighlightRules = function() {
|
||||
|
||||
var constantLanguage = "true|false";
|
||||
var keywordControl = "with|import|if|else|then";
|
||||
var keywordDeclaration = "let|in|rec";
|
||||
var constantLanguage = "true|false";
|
||||
var keywordControl = "with|import|if|else|then";
|
||||
var keywordDeclaration = "let|in|rec";
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"constant.language.nix": constantLanguage,
|
||||
"keyword.control.nix": keywordControl,
|
||||
"keyword.declaration.nix": keywordDeclaration
|
||||
}, "identifier");
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"constant.language.nix": constantLanguage,
|
||||
"keyword.control.nix": keywordControl,
|
||||
"keyword.declaration.nix": keywordDeclaration
|
||||
}, "identifier");
|
||||
|
||||
this.$rules = {
|
||||
"start": [{
|
||||
token: "comment",
|
||||
regex: /#.*$/
|
||||
}, {
|
||||
token: "comment",
|
||||
regex: /\/\*/,
|
||||
next: "comment"
|
||||
}, {
|
||||
regex: "(==|!=|<=?|>=?)",
|
||||
token: ["keyword.operator.comparison.nix"]
|
||||
}, {
|
||||
regex: "((?:[+*/%-]|\\~)=)",
|
||||
token: ["keyword.operator.assignment.arithmetic.nix"]
|
||||
}, {
|
||||
regex: "=",
|
||||
token: "keyword.operator.assignment.nix"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: "''",
|
||||
next: "qqdoc"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: "'",
|
||||
next: "qstring"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: '"',
|
||||
next: "qqstring"
|
||||
}, {
|
||||
token: "constant.numeric", // hex
|
||||
regex: "0[xX][0-9a-fA-F]+\\b"
|
||||
}, {
|
||||
token: "constant.numeric", // float
|
||||
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token: keywordMapper,
|
||||
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}],
|
||||
"comment": [{
|
||||
token: "comment", // closing comment
|
||||
regex: ".*?\\*\\/",
|
||||
next: "start"
|
||||
}, {
|
||||
token: "comment", // comment spanning whole line
|
||||
regex: ".+"
|
||||
}],
|
||||
"qqdoc": [{
|
||||
token: "constant.language.escape",
|
||||
regex: /\$\{[^}]+\}/
|
||||
}, {
|
||||
token: "string",
|
||||
regex: "''",
|
||||
next: "start"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}],
|
||||
this.$rules = {
|
||||
"start": [{
|
||||
token: "comment",
|
||||
regex: /#.*$/
|
||||
}, {
|
||||
token: "comment",
|
||||
regex: /\/\*/,
|
||||
next: "comment"
|
||||
}, {
|
||||
token: "constant",
|
||||
regex: "<[^>]+>"
|
||||
}, {
|
||||
regex: "(==|!=|<=?|>=?)",
|
||||
token: ["keyword.operator.comparison.nix"]
|
||||
}, {
|
||||
regex: "((?:[+*/%-]|\\~)=)",
|
||||
token: ["keyword.operator.assignment.arithmetic.nix"]
|
||||
}, {
|
||||
regex: "=",
|
||||
token: "keyword.operator.assignment.nix"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: "''",
|
||||
next: "qqdoc"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: "'",
|
||||
next: "qstring"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: '"',
|
||||
push: "qqstring"
|
||||
}, {
|
||||
token: "constant.numeric", // hex
|
||||
regex: "0[xX][0-9a-fA-F]+\\b"
|
||||
}, {
|
||||
token: "constant.numeric", // float
|
||||
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token: keywordMapper,
|
||||
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
regex: "}",
|
||||
token: function(val, start, stack) {
|
||||
return stack[1] == "qqstring" ? "constant.language.escape" : "text"
|
||||
},
|
||||
next: "pop"
|
||||
}],
|
||||
"comment": [{
|
||||
token: "comment", // closing comment
|
||||
regex: ".*?\\*\\/",
|
||||
next: "start"
|
||||
}, {
|
||||
token: "comment", // comment spanning whole line
|
||||
regex: ".+"
|
||||
}],
|
||||
"qqdoc": [
|
||||
{
|
||||
token: "constant.language.escape",
|
||||
regex: /\$\{/,
|
||||
push: "start"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: "''",
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}],
|
||||
"qqstring": [
|
||||
{
|
||||
token: "constant.language.escape",
|
||||
regex: /\$\{/,
|
||||
push: "start"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: '"',
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}],
|
||||
"qstring": [
|
||||
{
|
||||
token: "constant.language.escape",
|
||||
regex: /\$\{/,
|
||||
push: "start"
|
||||
}, {
|
||||
token: "string",
|
||||
regex: "'",
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
};
|
||||
|
||||
"qqstring": [{
|
||||
token: "constant.language.escape",
|
||||
regex: /\$\{[^}]+\}/
|
||||
}, {
|
||||
token: "string",
|
||||
regex: '"',
|
||||
next: "start"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}],
|
||||
|
||||
"qstring": [{
|
||||
token: "constant.language.escape",
|
||||
regex: /\$\{[^}]+\}/
|
||||
}, {
|
||||
token: "string",
|
||||
regex: "'",
|
||||
next: "start"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
};
|
||||
oop.inherits(NixHighlightRules, TextHighlightRules);
|
||||
|
||||
oop.inherits(NixHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.NixHighlightRules = NixHighlightRules;
|
||||
exports.NixHighlightRules = NixHighlightRules;
|
||||
});
|
||||
7
lib/ace/snippets/nix.js
Normal file
7
lib/ace/snippets/nix.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./nix.snippets");
|
||||
exports.scope = "nix";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/nix.snippets
Normal file
0
lib/ace/snippets/nix.snippets
Normal file
Loading…
Add table
Add a link
Reference in a new issue