Skip to content

Commit aa85c46

Browse files
committed
updated scintillua lexer a bit, added moon theme
1 parent 6aac4c4 commit aa85c46

File tree

2 files changed

+85
-18
lines changed

2 files changed

+85
-18
lines changed

extra/scintillua/lexers/moonscript.lua

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ local comment = token(l.COMMENT, block_comment + line_comment)
2727
-- Strings.
2828
local sq_str = l.delimited_range("'", '\\', true)
2929
local dq_str = l.delimited_range('"', '\\', true)
30-
local regex_str = l.delimited_range('/', '\\', nil, nil, '\n') * S('igm')^0
31-
local string = token(l.STRING, sq_str + dq_str) + P(function(input, index)
32-
if index == 1 then return index end
33-
local i = index
34-
while input:sub(i - 1, i - 1):match('[ \t\r\n\f]') do i = i - 1 end
35-
return input:sub(i - 1, i - 1):match('[+%-*%%^!=&|?:;,()%[%]{}]') and index
36-
end) * token('regex', regex_str) + token('longstring', longstring)
30+
local string = token(l.STRING, sq_str + dq_str + longstring)
3731

3832
-- Numbers.
3933
local number = token(l.NUMBER, l.float + l.integer)
@@ -44,11 +38,13 @@ local keyword = token(l.KEYWORD, word_match {
4438
'if', 'else', 'elseif', 'then', 'export',
4539
'import', 'from', 'with', 'in', 'and',
4640
'or', 'not', 'class', 'extends', 'super', 'do',
47-
'true', 'false', 'nil', 'using', 'switch', 'when',
41+
'using', 'switch', 'when',
4842
})
4943

44+
local special = token("special", word_match { "true", "false", "nil" })
45+
5046
-- Functions.
51-
local func = token(l.FUNCTION, word_match {
47+
local builtin = token(l.FUNCTION, word_match {
5248
'assert', 'collectgarbage', 'dofile', 'error', 'getfenv', 'getmetatable',
5349
'ipairs', 'load', 'loadfile', 'loadstring', 'module', 'next', 'pairs',
5450
'pcall', 'print', 'rawequal', 'rawget', 'rawset', 'require', 'setfenv',
@@ -58,34 +54,44 @@ local func = token(l.FUNCTION, word_match {
5854
-- Identifiers.
5955
local identifier = token(l.IDENTIFIER, l.word)
6056

57+
local fndef = token("fndef", P"->" + P"=>")
58+
local err = token(l.ERROR, word_match { "function", "end" })
59+
6160
-- Operators.
62-
local operator = token(l.OPERATOR, '~=' + S('+-*!\\/%^#=<>;:,.{}[]()'))
61+
local symbol = token("symbol", S("(){}[]"))
62+
local operator = token(l.OPERATOR, '~=' + S('+-*!\\/%^#=<>;:,.'))
6363

6464
-- self ref
65-
local self_var = token('self_ref', "@" * l.word + "self")
65+
local self_var = token("self_ref", "@" * l.word + "self")
6666

67-
local proper_ident = token('proper_ident', R("AZ") * l.word)
67+
local proper_ident = token("proper_ident", R("AZ") * l.word)
6868

6969
_rules = {
7070
{ 'whitespace', ws },
71+
{ 'error', err },
7172
{ 'self', self_var },
73+
{ 'special', special },
7274
{ 'keyword', keyword },
73-
{ 'function', func },
75+
{ 'builtin', builtin },
7476
{ 'identifier', proper_ident + identifier },
7577
{ 'comment', comment },
7678
{ 'number', number },
7779
{ 'string', string },
80+
{ 'fndef', fndef },
81+
{ 'symbol', symbol },
7882
{ 'operator', operator },
7983
{ 'any_char', l.any_char },
8084
}
8185

82-
local pink = l.color("ED", "4E", "78")
86+
local style_special = { fore = l.colors.light_blue }
87+
local style_fndef = { fore = l.colors.green }
8388

8489
_tokenstyles = {
85-
{ 'regex', l.style_string..{ back = l.color('44', '44', '44')} },
86-
{ 'longstring', l.style_string },
87-
{ 'self_ref', { fore = l.colors.purple } },
88-
{ 'proper_ident', { fore = pink, bold = true } },
90+
{ 'self_ref', style_special },
91+
{ 'proper_ident', l.style_class },
92+
{ 'fndef', style_fndef },
93+
{ 'symbol', style_fndef },
94+
{ 'special', style_special },
8995
{ l.OPERATOR, { fore = l.colors.red, bold = true } },
9096
{ l.FUNCTION, { fore = l.colors.orange } },
9197
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
-- Copyright 2006-2011 Mitchell mitchell<att>caladbolg.net. See LICENSE.
2+
-- moon lexer theme for Scintillua.
3+
4+
module('lexer', package.seeall)
5+
6+
colors = {
7+
green = color('9F', 'FF', '98'), --
8+
blue = color('94', '95', 'FF'), --
9+
light_blue = color('98', 'D9', 'FF'), --
10+
red = color('FF', '98', '98'), --
11+
bright_red = color("F9", "26", "32"), --
12+
yellow = color('FF', 'E8', '98'), --
13+
teal = color('4D', '99', '99'),
14+
white = color('FF', 'FF', 'FF'), --
15+
black = color('2E', '2E', '2E'), --
16+
grey = color('92', '92', '92'), --
17+
purple = color('CB', '98', 'FF'), --
18+
orange = color('FF', '92', '00'), --
19+
pink = color("ED", "4E", "78"), --
20+
}
21+
22+
style_nothing = style { }
23+
style_char = style { fore = colors.red, bold = true }
24+
style_class = style { fore = colors.light_blue, bold = true }
25+
style_comment = style { fore = colors.grey, }
26+
style_constant = style { fore = colors.teal, bold = true }
27+
style_definition = style { fore = colors.red, bold = true }
28+
style_error = style { fore = colors.white, back = colors.bright_red, bold = true}
29+
style_function = style { fore = colors.white, bold = true }
30+
style_keyword = style { fore = colors.purple, bold = true }
31+
style_number = style { fore = colors.blue }
32+
style_operator = style { fore = colors.white, bold = true }
33+
style_string = style { fore = colors.yellow, bold = true }
34+
style_preproc = style { fore = colors.light_blue }
35+
style_tag = style { fore = colors.teal, bold = true }
36+
style_type = style { fore = colors.green }
37+
style_variable = style { fore = colors.white, italic = true }
38+
style_embedded = style_tag..{ back = color('44', '44', '44') }
39+
style_identifier = style_nothing
40+
41+
-- Default styles.
42+
local font_face = '!Bitstream Vera Sans Mono'
43+
local font_size = 12
44+
if WIN32 then
45+
font_face = not GTK and 'Courier New' or '!Courier New'
46+
elseif OSX then
47+
font_face = '!Monaco'
48+
font_size = 12
49+
end
50+
style_default = style{
51+
font = font_face,
52+
size = font_size,
53+
fore = colors.white,
54+
back = colors.black
55+
}
56+
style_line_number = style { fore = colors.black, back = colors.grey }
57+
style_bracelight = style { fore = color('66', '99', 'FF'), bold = true }
58+
style_bracebad = style { fore = color('FF', '66', '99'), bold = true }
59+
style_controlchar = style_nothing
60+
style_indentguide = style { fore = colors.grey, back = colors.white }
61+
style_calltip = style { fore = colors.white, back = color('44', '44', '44') }

0 commit comments

Comments
 (0)