Updated codemirror to v4.12.
Did a lot of cleanup to limit the size of the plugin. I kept the emmet plugin.
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2013 Kenneth Bentley
|
||||
Modified from the CoffeeScript CodeMirror mode, Copyright (c) 2011 Jeff Pickhardt
|
||||
Modified from the Python CodeMirror mode, Copyright (c) 2010 Timothy Farrell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -10,12 +10,12 @@
|
||||
<script src="livescript.js"></script>
|
||||
<style>.CodeMirror {font-size: 80%;border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
@@ -454,6 +454,6 @@ export prelude = out$
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-livescript</code>.</p>
|
||||
|
||||
<p>The LiveScript mode was written by Kenneth Bentley (<a href="LICENSE">license</a>).</p>
|
||||
<p>The LiveScript mode was written by Kenneth Bentley.</p>
|
||||
|
||||
</article>
|
||||
|
||||
@@ -1,19 +1,32 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
/**
|
||||
* Link to the project's GitHub page:
|
||||
* https://github.com/duralog/CodeMirror
|
||||
*/
|
||||
(function() {
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode('livescript', function(){
|
||||
var tokenBase, external;
|
||||
tokenBase = function(stream, state){
|
||||
var next_rule, nr, i$, len$, r, m;
|
||||
if (next_rule = state.next || 'start') {
|
||||
var tokenBase = function(stream, state) {
|
||||
var next_rule = state.next || "start";
|
||||
if (next_rule) {
|
||||
state.next = state.next;
|
||||
if (Array.isArray(nr = Rules[next_rule])) {
|
||||
for (i$ = 0, len$ = nr.length; i$ < len$; ++i$) {
|
||||
r = nr[i$];
|
||||
var nr = Rules[next_rule];
|
||||
if (nr.splice) {
|
||||
for (var i$ = 0; i$ < nr.length; ++i$) {
|
||||
var r = nr[i$], m;
|
||||
if (r.regex && (m = stream.match(r.regex))) {
|
||||
state.next = r.next;
|
||||
state.next = r.next || state.next;
|
||||
return r.token;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +46,7 @@
|
||||
stream.next();
|
||||
return 'error';
|
||||
};
|
||||
external = {
|
||||
var external = {
|
||||
startState: function(){
|
||||
return {
|
||||
next: 'start',
|
||||
@@ -41,8 +54,8 @@
|
||||
};
|
||||
},
|
||||
token: function(stream, state){
|
||||
var style;
|
||||
style = tokenBase(stream, state);
|
||||
while (stream.pos == stream.start)
|
||||
var style = tokenBase(stream, state);
|
||||
state.lastToken = {
|
||||
style: style,
|
||||
indent: stream.indentation(),
|
||||
@@ -51,8 +64,7 @@
|
||||
return style.replace(/\./g, ' ');
|
||||
},
|
||||
indent: function(state){
|
||||
var indentation;
|
||||
indentation = state.lastToken.indent;
|
||||
var indentation = state.lastToken.indent;
|
||||
if (state.lastToken.content.match(indenter)) {
|
||||
indentation += 2;
|
||||
}
|
||||
@@ -192,7 +204,7 @@
|
||||
next: 'start'
|
||||
}, {
|
||||
token: 'text',
|
||||
regex: '.',
|
||||
regex: '',
|
||||
next: 'start'
|
||||
}
|
||||
],
|
||||
@@ -251,17 +263,18 @@
|
||||
};
|
||||
for (var idx in Rules) {
|
||||
var r = Rules[idx];
|
||||
if (Array.isArray(r)) {
|
||||
if (r.splice) {
|
||||
for (var i = 0, len = r.length; i < len; ++i) {
|
||||
var rr = r[i];
|
||||
if (rr.regex) {
|
||||
if (typeof rr.regex === 'string') {
|
||||
Rules[idx][i].regex = new RegExp('^' + rr.regex);
|
||||
}
|
||||
}
|
||||
} else if (r.regex) {
|
||||
} else if (typeof rr.regex === 'string') {
|
||||
Rules[idx].regex = new RegExp('^' + r.regex);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
CodeMirror.defineMIME('text/x-livescript', 'livescript');
|
||||
CodeMirror.defineMIME('text/x-livescript', 'livescript');
|
||||
|
||||
});
|
||||
|
||||
@@ -1,266 +0,0 @@
|
||||
/**
|
||||
* Link to the project's GitHub page:
|
||||
* https://github.com/duralog/CodeMirror
|
||||
*/
|
||||
CodeMirror.defineMode 'livescript', (conf) ->
|
||||
tokenBase = (stream, state) ->
|
||||
#indent =
|
||||
if next_rule = state.next or \start
|
||||
state.next = state.next
|
||||
if Array.isArray nr = Rules[next_rule]
|
||||
for r in nr
|
||||
if r.regex and m = stream.match r.regex
|
||||
state.next = r.next
|
||||
return r.token
|
||||
stream.next!
|
||||
return \error
|
||||
if stream.match r = Rules[next_rule]
|
||||
if r.regex and stream.match r.regex
|
||||
state.next = r.next
|
||||
return r.token
|
||||
else
|
||||
stream.next!
|
||||
return \error
|
||||
stream.next!
|
||||
return 'error'
|
||||
external = {
|
||||
startState: (basecolumn) ->
|
||||
{
|
||||
next: \start
|
||||
lastToken: null
|
||||
}
|
||||
token: (stream, state) ->
|
||||
style = tokenBase stream, state #tokenLexer stream, state
|
||||
state.lastToken = {
|
||||
style: style
|
||||
indent: stream.indentation!
|
||||
content: stream.current!
|
||||
}
|
||||
style.replace /\./g, ' '
|
||||
indent: (state, textAfter) ->
|
||||
# XXX this won't work with backcalls
|
||||
indentation = state.lastToken.indent
|
||||
if state.lastToken.content.match indenter then indentation += 2
|
||||
return indentation
|
||||
}
|
||||
external
|
||||
|
||||
### Highlight Rules
|
||||
# taken from mode-ls.ls
|
||||
|
||||
indenter = // (?
|
||||
: [({[=:]
|
||||
| [-~]>
|
||||
| \b (?: e(?:lse|xport) | d(?:o|efault) | t(?:ry|hen) | finally |
|
||||
import (?:\s* all)? | const | var |
|
||||
let | new | catch (?:\s* #identifier)? )
|
||||
) \s* $ //
|
||||
|
||||
identifier = /(?![\d\s])[$\w\xAA-\uFFDC](?:(?!\s)[$\w\xAA-\uFFDC]|-[A-Za-z])*/$
|
||||
keywordend = /(?![$\w]|-[A-Za-z]|\s*:(?![:=]))/$
|
||||
stringfill = token: \string, regex: '.+'
|
||||
|
||||
Rules =
|
||||
start:
|
||||
* token: \comment.doc
|
||||
regex: '/\\*'
|
||||
next : \comment
|
||||
|
||||
* token: \comment
|
||||
regex: '#.*'
|
||||
|
||||
* token: \keyword
|
||||
regex: //(?
|
||||
:t(?:h(?:is|row|en)|ry|ypeof!?)
|
||||
|c(?:on(?:tinue|st)|a(?:se|tch)|lass)
|
||||
|i(?:n(?:stanceof)?|mp(?:ort(?:\s+all)?|lements)|[fs])
|
||||
|d(?:e(?:fault|lete|bugger)|o)
|
||||
|f(?:or(?:\s+own)?|inally|unction)
|
||||
|s(?:uper|witch)
|
||||
|e(?:lse|x(?:tends|port)|val)
|
||||
|a(?:nd|rguments)
|
||||
|n(?:ew|ot)
|
||||
|un(?:less|til)
|
||||
|w(?:hile|ith)
|
||||
|o[fr]|return|break|let|var|loop
|
||||
)//$ + keywordend
|
||||
|
||||
* token: \constant.language
|
||||
regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
|
||||
|
||||
* token: \invalid.illegal
|
||||
regex: '(?
|
||||
:p(?:ackage|r(?:ivate|otected)|ublic)
|
||||
|i(?:mplements|nterface)
|
||||
|enum|static|yield
|
||||
)' + keywordend
|
||||
|
||||
* token: \language.support.class
|
||||
regex: '(?
|
||||
:R(?:e(?:gExp|ferenceError)|angeError)
|
||||
|S(?:tring|yntaxError)
|
||||
|E(?:rror|valError)
|
||||
|Array|Boolean|Date|Function|Number|Object|TypeError|URIError
|
||||
)' + keywordend
|
||||
|
||||
* token: \language.support.function
|
||||
regex: '(?
|
||||
:is(?:NaN|Finite)
|
||||
|parse(?:Int|Float)
|
||||
|Math|JSON
|
||||
|(?:en|de)codeURI(?:Component)?
|
||||
)' + keywordend
|
||||
|
||||
* token: \variable.language
|
||||
regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
|
||||
|
||||
* token: \identifier
|
||||
regex: identifier + /\s*:(?![:=])/$
|
||||
|
||||
* token: \variable
|
||||
regex: identifier
|
||||
|
||||
* token: \keyword.operator
|
||||
regex: /(?:\.{3}|\s+\?)/$
|
||||
|
||||
* token: \keyword.variable
|
||||
regex: /(?:@+|::|\.\.)/$
|
||||
next : \key
|
||||
|
||||
* token: \keyword.operator
|
||||
regex: /\.\s*/$
|
||||
next : \key
|
||||
|
||||
* token: \string
|
||||
regex: /\\\S[^\s,;)}\]]*/$
|
||||
|
||||
* token: \string.doc
|
||||
regex: \'''
|
||||
next : \qdoc
|
||||
|
||||
* token: \string.doc
|
||||
regex: \"""
|
||||
next : \qqdoc
|
||||
|
||||
* token: \string
|
||||
regex: \'
|
||||
next : \qstring
|
||||
|
||||
* token: \string
|
||||
regex: \"
|
||||
next : \qqstring
|
||||
|
||||
* token: \string
|
||||
regex: \`
|
||||
next : \js
|
||||
|
||||
* token: \string
|
||||
regex: '<\\['
|
||||
next : \words
|
||||
|
||||
* token: \string.regex
|
||||
regex: \//
|
||||
next : \heregex
|
||||
|
||||
* token: \string.regex
|
||||
regex: //
|
||||
/(?: [^ [ / \n \\ ]*
|
||||
(?: (?: \\.
|
||||
| \[ [^\]\n\\]* (?:\\.[^\]\n\\]*)* \]
|
||||
) [^ [ / \n \\ ]*
|
||||
)*
|
||||
)/ [gimy$]{0,4}
|
||||
//$
|
||||
next : \key
|
||||
|
||||
* token: \constant.numeric
|
||||
regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*
|
||||
|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*
|
||||
|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)
|
||||
(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
|
||||
|
||||
* token: \lparen
|
||||
regex: '[({[]'
|
||||
|
||||
* token: \rparen
|
||||
regex: '[)}\\]]'
|
||||
next : \key
|
||||
|
||||
* token: \keyword.operator
|
||||
regex: \\\S+
|
||||
|
||||
* token: \text
|
||||
regex: \\\s+
|
||||
|
||||
heregex:
|
||||
* token: \string.regex
|
||||
regex: '.*?//[gimy$?]{0,4}'
|
||||
next : \start
|
||||
* token: \string.regex
|
||||
regex: '\\s*#{'
|
||||
* token: \comment.regex
|
||||
regex: '\\s+(?:#.*)?'
|
||||
* token: \string.regex
|
||||
regex: '\\S+'
|
||||
|
||||
key:
|
||||
* token: \keyword.operator
|
||||
regex: '[.?@!]+'
|
||||
* token: \identifier
|
||||
regex: identifier
|
||||
next : \start
|
||||
* token: \text
|
||||
regex: '.'
|
||||
next : \start
|
||||
|
||||
comment:
|
||||
* token: \comment.doc
|
||||
regex: '.*?\\*/'
|
||||
next : \start
|
||||
* token: \comment.doc
|
||||
regex: '.+'
|
||||
|
||||
qdoc:
|
||||
token: \string
|
||||
regex: ".*?'''"
|
||||
next : \key
|
||||
stringfill
|
||||
|
||||
qqdoc:
|
||||
token: \string
|
||||
regex: '.*?"""'
|
||||
next : \key
|
||||
stringfill
|
||||
|
||||
qstring:
|
||||
token: \string
|
||||
regex: /[^\\']*(?:\\.[^\\']*)*'/$
|
||||
next : \key
|
||||
stringfill
|
||||
|
||||
qqstring:
|
||||
token: \string
|
||||
regex: /[^\\"]*(?:\\.[^\\"]*)*"/$
|
||||
next : \key
|
||||
stringfill
|
||||
|
||||
js:
|
||||
token: \string
|
||||
regex: /[^\\`]*(?:\\.[^\\`]*)*`/$
|
||||
next : \key
|
||||
stringfill
|
||||
|
||||
words:
|
||||
token: \string
|
||||
regex: '.*?\\]>'
|
||||
next : \key
|
||||
stringfill
|
||||
|
||||
# for optimization, precompile the regexps
|
||||
for idx, r of Rules
|
||||
if Array.isArray r
|
||||
for rr, i in r
|
||||
if rr.regex then Rules[idx][i].regex = new RegExp '^'+rr.regex
|
||||
else if r.regex then Rules[idx].regex = new RegExp '^'+r.regex
|
||||
|
||||
CodeMirror.defineMIME 'text/x-livescript', 'livescript'
|
||||
Reference in New Issue
Block a user