I have followed the wiki to write a custom pretty printer, pret-ada.lua. I placed it next to my tex file.
The wiki says that I have to use \installprettytype to register it. However, it yields Undefined control sequence. Some digging revealed a mailing list post which explains that it has been removed in MkIV. But it does not explain how I register my pretty printer with ConTeXt now.
So, how can I make ConTeXt use my pretty printer? Just removing the command leads to no pretty printing at all:
%\installprettytype[ADA][ADA] % Undefined control sequence!
\definetyping[Ada][option=ADA]
\starttext
\startAda
A := "String";
\stopAda
\stoptext
Edit
Here's what I have come up with so far for the lexer. It is most probably horribly wrong because I could not test it yet. I copied parts of it from pret-c.lua.
local keywords = {
"abort", "abs", "abstract", "accept", "access", "aliased", "all", "and",
"array", "at", "begin", "body", "case", "constant", "declare", "delay",
"delta", "digits", "do", "else", "elsif", "end", "entry", "exception",
"exit", "for", "function", "generic", "goto", "if", "in", "interface", "is",
"limited", "loop", "mod", "new", "not", "null", "of", "or", "others", "out",
"overriding", "package", "pragma", "private", "procedure", "protected",
"raise", "range", "record", "rem", "renames", "requeue", "return", "reverse",
"select", "separate", "some", "subtype", "synchronized", "tagged", "task",
"terminate", "then", "type", "until", "use", "when", "while", "with", "xor"
}
local keyword_colors = {}
for _, n in ipairs(keywords) do
keyword_colors[n] = "keyword"
end
local colors = {
{name = "comment", color="gray"},
{name = "keyword", color="blue"},
{name = "string", color="green"}
}
local color
local function init()
color = 0
local def_colors = ""
local palet = "\\definepalet[Ccolorpretty]["
for _, c in ipairs(colors) do
def_colors = format("%s\\doifcolorelese{C%s}{}{\\definecolor[C%s][%s]}",
def_colors, c.name, c.name, c.color)
palet = format("%s%s=C%s,", palet, c.name, c.name)
end
palet = palet:gsub("(.+),$", "%1]")
texsprint(def_colors)
texsprint(palet)
buffers.currentcolors = {}
for i, c in ipairs(colors) do
buffers.currentcolors[i] = c.name
end
end
local function finish_color()
color = buffers.finishstate(color)
end
local function change_color(n)
color = buffers.changestate(color_by_name[n], color)
end
local visualizer = buffers.newvisualizer('ada')
visualizer.begin_of_display = init
visualizer.begin_of_inline = init
visualizer.end_of_display = finish_color
visualizer.end_of_inline = finish_color
local function next_token(lexer)
local buf = ""
if lexer.c == " " or lexer.c == "\t" then
buf = lexer.c
lexer.c = lexer.next()
while lexer.c == " " or lexer.c == "\t" do
buf = buf .. lexer.c
lexer.c = lexer.next()
end
elseif lexer.c = "\"" then
while true do
lexer.c = lexer.next()
if lexer.c == nil then break end
buf = buf .. lexer.c
if lexer.c == "\"" then break end
end
elseif lexer.c == "-" then
buf = buf .. lexer.c
lexer.c = lexer.next()
if lexer.c == "-" then
while lexer.c ~= nil do
buf = buf .. lexer.c
lexer.c = lexer.next()
end
end
elseif lexer.c:match("[%w_]") then
while lexer.c != nil and lexer.c:match("[%w_]") do
buf = buf .. lexer.c
lexer.c = lexer.next()
end
else
buf = lexer.c
lexer.c = lexer.next()
end
return buf
end
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
function visualizer.flush_line(str, nested)
local lexer = {
next = utfcharacters(str)
}
lexer.c = lexer.next()
while lexer.c ~= nil do
local token = next_token(lexer)
if token:starts("--") then
change_color("comment")
texsprint(token)
finish_color()
elseif token:starts("\"") then
change_color("string")
texsprint(token)
finish_color()
elseif keyword_colors[token] then
change_color("keyword")
texsprint(token)
finish_color()
else
texsprint(token)
end
end
end


buff-imp-lua.luaandbuff-imp-lua.mkiv. However, you might be very interested in Aditya'svimhighlighter module. It uses an external program (vim) but supports all sorts of files. – Henri Menke Oct 10 '16 at 15:38