summaryrefslogtreecommitdiff
path: root/context/data/scite/context/lexers/scite-context-lexer-tex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'context/data/scite/context/lexers/scite-context-lexer-tex.lua')
-rw-r--r--context/data/scite/context/lexers/scite-context-lexer-tex.lua57
1 files changed, 38 insertions, 19 deletions
diff --git a/context/data/scite/context/lexers/scite-context-lexer-tex.lua b/context/data/scite/context/lexers/scite-context-lexer-tex.lua
index 4787263a3..2c2421d2f 100644
--- a/context/data/scite/context/lexers/scite-context-lexer-tex.lua
+++ b/context/data/scite/context/lexers/scite-context-lexer-tex.lua
@@ -57,24 +57,36 @@ do -- todo: only once, store in global
local definitions = context.loaddefinitions("scite-context-data-interfaces")
if definitions then
- local list = { }
+ local used = { }
for interface, list in next, definitions do
- list[#list+1] = interface
- local c = { }
- for i=1,#list do
- c[list[i]] = true
- end
- if interface ~= "en" then
+ if interface ~= "common" then
+ used[#used+1] = interface
+ local c = { }
+ -- these are shared
+ local list = definitions.common
+ if list then
+ for i=1,#list do
+ c[list[i]] = true
+ end
+ end
+ -- normally this one is empty
list = definitions.en
if list then
for i=1,#list do
c[list[i]] = true
end
end
+ -- these are interface specific
+ if interface ~= "en" then
+ for i=1,#list do
+ c[list[i]] = true
+ end
+ end
+ commands[interface] = c
end
- commands[interface] = c
end
- inform("context user interfaces '%s' supported",table.concat(list," "))
+ table.sort(used)
+ inform("context user interfaces '%s' supported",table.concat(used," "))
end
local definitions = context.loaddefinitions("scite-context-data-context")
@@ -222,10 +234,12 @@ local p_comment = commentline
----- p_helper = backslash * exact_match(helpers)
----- p_primitive = backslash * exact_match(primitives)
-local p_command = backslash * lexer.helpers.utfchartabletopattern(currentcommands) * #(1-cstoken)
-local p_constant = backslash * lexer.helpers.utfchartabletopattern(constants) * #(1-cstoken)
-local p_helper = backslash * lexer.helpers.utfchartabletopattern(helpers) * #(1-cstoken)
-local p_primitive = backslash * lexer.helpers.utfchartabletopattern(primitives) * #(1-cstoken)
+local p_csdone = #(1-cstoken) + P(-1)
+
+local p_command = backslash * lexer.helpers.utfchartabletopattern(currentcommands) * p_csdone
+local p_constant = backslash * lexer.helpers.utfchartabletopattern(constants) * p_csdone
+local p_helper = backslash * lexer.helpers.utfchartabletopattern(helpers) * p_csdone
+local p_primitive = backslash * lexer.helpers.utfchartabletopattern(primitives) * p_csdone
local p_ifprimitive = P("\\if") * cstoken^1
local p_csname = backslash * (cstoken^1 + P(1))
@@ -403,7 +417,7 @@ local luaenvironment = P("lua") * (P("setups") + P("code") + P(true))
local inlinelua = P("\\") * (
P("ctx") * (P("lua") + P("command") + P("late") * (P("lua") + P("command")) + P("function"))
+ P("cld") * (P("command") + P("context"))
- + P("luaexpr")
+ + P("lua") * (P("expr") + P("script") + P("thread"))
+ (P("direct") + P("late")) * P("lua")
)
@@ -448,12 +462,17 @@ local stopmetafuncode = token("embedded", stopmetafun)
local callers = token("embedded", P("\\") * metafuncall) * metafunarguments
+ token("embedded", P("\\") * luacall)
-lexer.embed_lexer(contextlexer, cldlexer, startluacode, stopluacode)
lexer.embed_lexer(contextlexer, mpslexer, startmetafuncode, stopmetafuncode)
+lexer.embed_lexer(contextlexer, cldlexer, startluacode, stopluacode)
+
+-- preamble is inefficient as it probably gets called each time (so some day I really need to
+-- patch the plugin)
+
+contextlexer._preamble = preamble
contextlexer._rules = {
{ "whitespace", spacing },
- { "preamble", preamble },
+ -- { "preamble", preamble },
{ "word", word },
{ "text", text }, -- non words
{ "comment", comment },
@@ -461,10 +480,10 @@ contextlexer._rules = {
-- { "subsystem", subsystem },
{ "callers", callers },
{ "subsystem", subsystem },
+ { "ifprimitive", ifprimitive },
{ "helper", helper },
{ "command", command },
{ "primitive", primitive },
- { "ifprimitive", ifprimitive },
-- { "subsystem", subsystem },
{ "reserved", reserved },
{ "csname", csname },
@@ -492,10 +511,10 @@ if web then
{ "comment", comment },
{ "constant", constant },
{ "callers", callers },
+ { "ifprimitive", ifprimitive },
{ "helper", helper },
{ "command", command },
{ "primitive", primitive },
- { "ifprimitive", ifprimitive },
{ "reserved", reserved },
{ "csname", csname },
{ "grouping", grouping },
@@ -516,10 +535,10 @@ else
{ "comment", comment },
{ "constant", constant },
{ "callers", callers },
+ { "ifprimitive", ifprimitive },
{ "helper", helper },
{ "command", command },
{ "primitive", primitive },
- { "ifprimitive", ifprimitive },
{ "reserved", reserved },
{ "csname", csname },
{ "grouping", grouping },